aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.51k stars 4.12k forks source link

aws s3 rm flag to remove all versions #4070

Open adamchainz opened 5 years ago

adamchainz commented 5 years ago

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 to rm could be added, to allow this?

justnance commented 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.

bsmith1310 commented 4 years ago

+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.

acdha commented 4 years ago

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.

tim-finnigan commented 2 years ago

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