How do I see which S3 buckets are empty?

Alan Newcomer
2 min readJul 4, 2019

--

If you are like me, you do not remove s3 buckets in your AWS account and always seem to have 99 of them. I always find myself deleting one bucket so I can just add another and not hit my S3 bucket default limit. I finally decided to go through and clean up the buckets that I no longer use. There are two things that I need to do.

How to decide which buckets to remove:
1. I know longer use or need the bucket.
2. The bucket is empty.

Option 1 seems like a lot of work and I am just going to stick with the lazy way. So I am going to start with finding all of the empty buckets that I have in my account and delete them. I would like to see in the console which S3 buckets are empty, but there isn’t a way. So I wrote a simple python lambda script that will identify empty buckets.

**Disclaimer, do not run this script on buckets that are used in a production environment. **

The Lambda function

If you are afraid of cost, simply set your lambda memory and timeout to a setting you are comfortable with. A maxed out (3 gig, 15 minute) function will still only run you about $0.05 after the free tier.

The views I express are mine alone and that they do not necessarily reflect the views of my employer.

--

--