Deleting an Amazon AWS S3 bucket with many thousands of files/keys

amazon s3amazon-web-services

Is there an easy way of deleting an Amazon S3 bucket that has many tens of thousands of objects within it? I've tried s3cmd with –recursive and –force, but it memory-bloats and has been running for days with little effect.

Best Answer

The new answer for deleting an Amazon S3 bucket with many thousands or millions of items in it is to use the new Object Expiration rules.

You can even do this from the AWS Console. Simply go to the properties of bucket you want to delete, open the LifeCycle tab and setup a new expiration rule with no prefix and 1 day to expire. Wait one day and the objects will be removed. If you have millions (as I have in my case) you could take a few days before the objects all actually disappear, however, you will be happy to note that you no longer pay for those stored items after the expiration period of 24 hours.

Note: The only limitation on this approach is that you can not set the lifecycle rules if you have versioning enabled.

Object Expiration