Just a quick note to myself of how to force the removal of a non-empty bucket in Amazon S3 that cannot be removed using the web interface. I recently needed to get rid of two ancient buckets and for some reason Amazon S3’s web GUI wouldn’t successfully empty and remove them. Some of the offending files turned out to be named ‘Icon’ and had a zero file size. After checking permissions and policies I did some digging and found this solution:

TL;DR Use the Amazon S3 CLI and force remove the bucket

aws s3 rb s3://%BUCKETNAME% --force

Here is the long version:

1. Download an install Amazon AWS CLI for your computer (Mac OS X in my case, there are versions for Linux and Windows too)

The full list of up to date links to download the CLI can be found on Amazon’s website.

2. Set up a new configuration for the account you want to force removing the bucket(s) for

aws configure

You will need to set the key, secret and region. Amazon S3 regions can be found on the handy list on their site.

3. List the bucket(s)

aws s3 ls

4. Force the deletion of the bucket in question (no emptying required)

aws s3 rb s3://%BUCKETNAME% --force

Not the –force bit at the end!

The bucket name is what ever your bucket is called – just copy and paste it from the ‘ls‘ command earlier.

If you want more information, check out the article on Amazon’s knowledge base.