Delete all your S3 buckets with ease
This is a quick ruby script that will delete all your S3 buckets in 24 hours.
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
# create a connection
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY'],
:aws_secret_access_key => ENV['AWS_SECRET_KEY']
})
life_cycle = {
"Rules" => [{
'Expiration' => { "Days" => 1, "Date" => Time.now.utc }
}]
}
connection.directories.each do |dir|
puts "DELETE #{dir.key}"
connection.put_bucket_lifecycle(dir.key, life_cycle)
end
USE WITH CAUTION HOLY SHIT
Written by Dave Newman
Related protips
1 Response
nice!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#