Open adamchainz opened 5 years ago
@adamchainz - Thanks for your post. Looks like this would be a great feature and similar to another feature request we are tracking under #1017. I'm going to keep you issue open pending further review and feedback.
+1 to this feature request. Having an easy way to (empty and) delete a bucket would be great.
Comments on #1017 suggest that simply disabling versioning on the bucket prevents the issue, but from what I'm seeing, that's not true. I have buckets that were never versioned, but aws s3 rm --recursive s3://mybucket
doesn't empty the bucket, the files remain in their 'soft' deleted state.
This (and #1017) is becoming more commonly encountered as tools based on the AWS or CIS security standards encourage enabling versioning for all buckets. It'd be nice if the AWS CLI could be used for normal operational practices without having a special case for this configuration.
Here is relevant documentation on deleting object versions from a versioning-enabled bucket: https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html
Also some suggestions from Stack Overflow: https://stackoverflow.com/questions/29809105/how-do-i-delete-a-versioned-bucket-in-aws-s3-using-the-cli
The S3 console has the 'empty' button which deletes all objects and versions thereof to clear a bucket before removal. This is very useful for cleaning up temporary buckets.
aws s3 rm --recursive s3://mybucket
doesn't work the same as "empty the versions, and there isn't a flag to remove all versions, so it's hard to automate complete S3 bucket removal.Perhaps a flag
--all-versions
torm
could be added, to allow this?