From 23a79ecc77ca767a13f027393fba63705e4a5e2c Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 4 Sep 2019 17:01:24 -0400 Subject: [PATCH] [stable-2.9] aws_s3 - wait for the bucket before setting ACLs (#61735) (#61768) * [stable-2.9] 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 * s3 - improve waiting for the bucket (#61802) (cherry picked from commit ff059912658b0dcccfb9c092081a820fcb7173d0) --- .../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..cfcfafd5661 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'): + # 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: