With Jabbakam we save a lot of images. All these images are stored in Amazon’s S3. Recently I thought I’d delete some of the test buckets.
Not as easy as I first thought. It turns out that you have to empty buckets before you can delete them. Fair enough, but there didn’t seem to be a way to easily bulk delete hundreds of images.
After some Googling I found Robert LaThanh’s S3Nukem which looked like it would do the job. All I needed to do now was fire up an EC2 instance, install and run. The steps were as follows:
- Create an EC2 instance on AWS (I used Ubuntu on a medium instance)
- make sure it is all up-to-date
apt-get update apt-get upgrade
- install ruby (if not already installed)
apt-get install ruby1.8 ruby1.8-dev
(not sure about ruby1.8-dev, but added just in case)
- install Ruby Gems
apt-get install rubygems
- install right_aws and s3nukem
gem install right_aws cd /tmp wget http://github.com/lathanh/s3nukem/raw/master/s3nukem --no-check-certificate chmod +x s3nukem
./s3nukem -t 20 -a -s
Several hours and over 15 million deleted images later it was all done and I shut down the instance.