sbulqw
Last Updated: September 24, 2016
·
1.169K
· whatupdave
Screen shot 2012 04 30 at 3.00

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

Say Thanks
Respond

1 Response
Add your response

28184
12003957 10206752435102297 2524621803006121539 n

nice!

over 1 year ago ·