From e93b8f054e73c2997bf9037ef768dc0dfd20c4ef Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 4 Sep 2019 09:42:28 -0400 Subject: [PATCH] [stable-2.8] aws_s3 - wait for the bucket before setting ACLs (#61735) * Wait for the bucket to become available if possible before setting ACLs (cherry picked from commit 91ccb03552) Co-authored-by: Sloane Hertel --- .../61735-wait-for-s3-bucket-to-exist-before-modifying.yaml | 2 ++ lib/ansible/modules/cloud/amazon/aws_s3.py | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 changelogs/fragments/61735-wait-for-s3-bucket-to-exist-before-modifying.yaml diff --git a/changelogs/fragments/61735-wait-for-s3-bucket-to-exist-before-modifying.yaml b/changelogs/fragments/61735-wait-for-s3-bucket-to-exist-before-modifying.yaml new file mode 100644 index 00000000000..808c22fcd5d --- /dev/null +++ b/changelogs/fragments/61735-wait-for-s3-bucket-to-exist-before-modifying.yaml @@ -0,0 +1,2 @@ +bugfixes: + - aws_s3 - Try to wait for the bucket to exist before setting the access control list. diff --git a/lib/ansible/modules/cloud/amazon/aws_s3.py b/lib/ansible/modules/cloud/amazon/aws_s3.py index 95e6f71b381..6798f26b0f2 100644 --- a/lib/ansible/modules/cloud/amazon/aws_s3.py +++ b/lib/ansible/modules/cloud/amazon/aws_s3.py @@ -389,6 +389,9 @@ def create_bucket(module, s3, bucket, location=None): s3.create_bucket(Bucket=bucket, CreateBucketConfiguration=configuration) else: s3.create_bucket(Bucket=bucket) + if module.params.get('permission') and not module.params.get('ignore_nonexistent_bucket'): + # Wait for the bucket to exist before setting ACLs + s3.get_waiter('bucket_exists').wait(Bucket=bucket) for acl in module.params.get('permission'): s3.put_bucket_acl(ACL=acl, Bucket=bucket) except botocore.exceptions.ClientError as e: