How to fix 'Access Denied' while deleting empty S3 Elastic Beanstalk?

Aero Wang picture Aero Wang · Oct 3, 2015 · Viewed 25.6k times · Source

I've noticed some Elastic Beanstalk is drawing about $20 to $30 every month on my AWS account and it turns out it is an empty S3 bucket.

I tried deleting it but it returns "Access Denied" error.

Access Denied

I also tried to use life cycle to remove it, but it also didn't work. Here is how I set up the life cycle:

Life Cycle

I set it to remove 1 day after creation

enter image description here

Answer

Rohit Banga picture Rohit Banga · Oct 6, 2015

Check the bucket policy on the S3 bucket. The bucket name seems to be the standard bucket that beanstalk creates to store your application versions, logs etc. To prevent accidental deletion of the bucket, the bucket policy denies delete permission. You can update the permissions on the S3 bucket policy to allow delete from your root account. Most likely your bucket policy currently does not allow deletion of the bucket. Then you will be able to delete the bucket.

Read more about S3 bucket permissions here: http://docs.aws.amazon.com/AmazonS3/latest/UG/EditingBucketPermissions.html