From 371c6dba8ba39af933877e5b3198723bcc2197f1 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Fri, 29 Sep 2017 06:20:10 +1000 Subject: [PATCH] Fix aws_s3 connection exception handling (#30955) `ProfileNotFound` does not have a `response` attribute, and `NoCredentialsError` does not occur at connection creation time. --- lib/ansible/modules/cloud/amazon/aws_s3.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/aws_s3.py b/lib/ansible/modules/cloud/amazon/aws_s3.py index d2551bc899..216d978d0e 100644 --- a/lib/ansible/modules/cloud/amazon/aws_s3.py +++ b/lib/ansible/modules/cloud/amazon/aws_s3.py @@ -609,9 +609,8 @@ def main(): aws_connect_kwargs.pop(key, None) try: s3 = get_s3_connection(module, aws_connect_kwargs, location, rgw, s3_url) - except (botocore.exceptions.NoCredentialsError, botocore.exceptions.ProfileNotFound) as e: - module.fail_json(msg="Can't authorize connection. Check your credentials and profile.", - exceptions=traceback.format_exc(), **camel_dict_to_snake_dict(e.response)) + except botocore.exceptions.ProfileNotFound as e: + module.fail_json(msg=to_native(e)) validate = not ignore_nonexistent_bucket