Last active
December 27, 2015 06:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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