Delete an S3 Bucket Containing Thousands of Files
A backup bucket I had on Amazon S3 (via Jungle Disk) had gotten out of control and was costing me too much. I decided to kill it off completely and take a different approach. So, I wanted to delete the bucket. I thought, easy, I'll just use Interarchy, pick the bucket, hit delete and be done. Nope. Interarchy kept choking on some of the files. I tried a few times. Turned to Transmit, failed as well. So, instead, a few lines of Ruby, via the aws-s3 gem, and I was done, with one caveat.
Assuming you have the aws-s3 gem installed, I just used IRB to do it. First there was setting up the connection, and then finding the bucket in question:require 'aws/s3'AWS::S3::Base.establish_connection!(:access_key_id => 'put-yer-key-here', :secret_access_key => 'put-ye-ole-secret-key-here')# Find the bucket the blunt way, by getting a list of the few I have, then picking the particular one (for me it was the second one in the array):buckets = AWS::S3::Service.bucketsevil_bucket = buckets[1]
while !evil_bucket.empty? puts "." evil_bucket.delete_allendevil_bucket.delete