From 91ccb03552f52fe4dd15366f0b378f4e23cedeb9 Mon Sep 17 00:00:00 2001 From: Sloane Hertel Date: Wed, 4 Sep 2019 09:42:28 -0400 Subject: [PATCH] aws_s3 - wait for the bucket before setting ACLs (#61735) * Wait for the bucket to become available if possible before setting ACLs --- .../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 00000000000000..808c22fcd5d49e --- /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 95e6f71b3813ca..6798f26b0f2c3e 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: