Skip to content

Instantly share code, notes, and snippets.

@whatupdave
Last active December 27, 2015 06:59
Show Gist options
  • Save whatupdave/7286124 to your computer and use it in GitHub Desktop.
Save whatupdave/7286124 to your computer and use it in GitHub Desktop.
Delete all your s3 buckets with lifecycle rules. USE WITH CAUTION HOLY SHIT
#!/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" => [{
"Enabled" => true,
'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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment