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: