How can I import the boto3 ssm ParameterNotFound exception?

前端 未结 2 1427
忘掉有多难
忘掉有多难 2021-02-12 15:48

I would like to import the exception that occurs when a boto3 ssm parameter is not found with get_parameter. I\

相关标签:
2条回答
  • 2021-02-12 16:19

    From Botocore Error Handling

    import boto3
    from botocore.exceptions import ClientError
    
    ssm = boto3.client('ssm')
    try:
        ssm.get_parameter(Name='not_found')
    except ClientError as e:
        print e.response['Error']['Code']
    
    0 讨论(0)
  • 2021-02-12 16:39
    mc = boto3.client('ssm')
    try:
      ...
    except mc.exceptions.ParameterNotFound:
      ...
    
    0 讨论(0)
提交回复
热议问题