Sunday, November 18, 2018

How to forcefully delete AWS S3 bucket

If you are unable to delete an AWS S3 bucket, it is likely an IAM user or a bucket policy that is denying the request. 

For example, when Elastic Beanstalk creates a bucket it adds a bucket policy to deny all bucket requests. The way to resolve this issue is to delete the bucket policy which will then allow you to delete the bucket.

With the S3 management console (https://console.aws.amazon.com/s3/home)
1. From the list of buckets, select the bucket you want to delete 
2. On the top right click on the "Properties" button
3. On the right panel expand the "Permissions" box
4. Click on the "Edit Bucket policy" button
5. In the Bucket Policy Editor prompt click on the "Delete" button, then "Ok"
6. Go back to the list of Buckets, right click on the bucket and from the drop down 
select "Delete" Instructions 

With the AWS CLI (http://aws.amazon.com/cli/):
1. aws s3api delete-bucket-policy --bucket your bucket name
2. aws s3 rb s3://your bucket name --force