Skip to content

Instantly share code, notes, and snippets.

@JNajera
Created October 29, 2013 20:56
Show Gist options
  • Select an option

  • Save JNajera/7222443 to your computer and use it in GitHub Desktop.

Select an option

Save JNajera/7222443 to your computer and use it in GitHub Desktop.
Delete all Amazon S3 buckets in console.
require "rubygems" # optional
require "aws/s3"
AWS::S3::Base.establish_connection!(
:access_key_id => 'INSERT_ACCESES_KEY_ID',
:secret_access_key => 'INSERT_SECRET_ACCESES_KEY')
buckets = AWS::S3::Service.buckets
puts 'Start deleting buckets...'
buckets.each_with_index do |bucket, index|
puts "Deleting #{bucket.name} bucket... (#{index+1}/#{buckets.count})"
AWS::S3::Bucket.delete(bucket.name, :force => true)
end
puts 'S3 buckets deleted...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment