diff --git a/changelogs/fragments/966-ignore_nonexistent_bucket_list.yml b/changelogs/fragments/966-ignore_nonexistent_bucket_list.yml new file mode 100644 index 00000000000..8fc2c14d491 --- /dev/null +++ b/changelogs/fragments/966-ignore_nonexistent_bucket_list.yml @@ -0,0 +1,2 @@ +bugfixes: +- s3_object - also use ``ignore_nonexistent_bucket`` when listing a bucket (https://github.com/ansible-collections/amazon.aws/issues/966). diff --git a/plugins/modules/s3_object.py b/plugins/modules/s3_object.py index dcefbcae674..7f979719eef 100644 --- a/plugins/modules/s3_object.py +++ b/plugins/modules/s3_object.py @@ -1168,10 +1168,9 @@ def main(): # Support for listing a set of keys if mode == 'list': - exists = bucket_check(module, s3, bucket) # If the bucket does not exist then bail out - if not exists: + if not bucketrtn: module.fail_json(msg="Target bucket (%s) cannot be found" % bucket) list_keys(module, s3, bucket, prefix, marker, max_keys)