diff --git a/changelogs/fragments/1538-s3-null.yml b/changelogs/fragments/1538-s3-null.yml new file mode 100644 index 00000000000..7c2ccfa6bd8 --- /dev/null +++ b/changelogs/fragments/1538-s3-null.yml @@ -0,0 +1,2 @@ +bugfixes: +- s3_bucket - fixes issue when deleting a bucket with unversioned objects (https://github.com/ansible-collections/amazon.aws/issues/1533). diff --git a/plugins/modules/s3_bucket.py b/plugins/modules/s3_bucket.py index c0a78e39a63..d242acc8399 100644 --- a/plugins/modules/s3_bucket.py +++ b/plugins/modules/s3_bucket.py @@ -1163,7 +1163,7 @@ def destroy_bucket(s3_client, module): # unversioned objects are deleted using `DeleteObject` # rather than `DeleteObjectVersion`, improving backwards # compatibility with older IAM policies. - if not fk.get("VersionId"): + if not fk.get("VersionId") or fk.get("VersionId") == "null": fk.pop("VersionId") if formatted_keys: