summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2019-09-04 17:01:24 -0400
committerToshio Kuratomi <a.badger@gmail.com>2019-09-04 14:01:24 -0700
commit23a79ecc77ca767a13f027393fba63705e4a5e2c (patch)
tree5c89720504434744d447c030779a55e81e8ca1e0
parent9ff8d8d898d4ed16e770d22041c7b0a99e87925d (diff)
downloadansible-23a79ecc77ca767a13f027393fba63705e4a5e2c.tar.gz
[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 <shertel@redhat.com> * s3 - improve waiting for the bucket (#61802) (cherry picked from commit ff059912658b0dcccfb9c092081a820fcb7173d0)
-rw-r--r--changelogs/fragments/61735-wait-for-s3-bucket-to-exist-before-modifying.yaml2
-rw-r--r--lib/ansible/modules/cloud/amazon/aws_s3.py3
2 files changed, 5 insertions, 0 deletions
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 0000000000..808c22fcd5
--- /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 95e6f71b38..cfcfafd566 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: