Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (12.9k points)

I have an S3 bucket that is 100% empty. Versioning was never enabled on the bucket. However, I still cannot remove the bucket. I have tried via the Console and the CLI tool. On the console it just says "Error" with no error message. From the cli and api it tells me: "An error occurred (BucketNotEmpty) when calling the DeleteBucket operation: The bucket you tried to delete is not empty". I have tried all of the following:

aws s3 rb s3://<bucket_name> --force -> BucketNotEmpty

aws s3 rm s3://<bucket_name> --recursive -> No output (because it's already empty)

aws s3api list-object-versions --bucket <bucket_name> -> No output (because versioning was never enabled)

aws s3api list-multipart-uploads --bucket <bucket_name> -> No outputs

aws s3api list-objects --delimiter=/ --prefix= --bucket <bucket_name> -> No Output (because it's empty)

  • It has no dependencies (it's not used by cloudfront or anything else that I'm aware of).
  • The bucket has been empty for approximately 5 days.
  • I was able to delete another very similar bucket with the same IAM user. Additionally, my IAM user has Admin access.

1 Answer

0 votes
by (18.2k points)

Seemingly, if your bucket is created using Elastic Beanstalk then it will be created with a deletion policy to prevent the user from accidentally deleting the bucket. So, in order the fix this issue, you will have to edit the bucket policy and then you should be able to delete the bucket using AWS S3 console.

As for deleting the bucket using AWS CLI, apart from the commands that you have already used, there's one more that you can try: 

aws s3 rb s3://bucketname --force --debug

Learn more about AWS by going through AWS course and master this trending technology.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

Browse Categories