How can I import the boto3 ssm ParameterNotFound exception?

前端 未结 2 1430
忘掉有多难
忘掉有多难 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']
    

提交回复
热议问题