Skip to content

Instantly share code, notes, and snippets.

@rabidpraxis
Created April 2, 2013 16:53
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rabidpraxis/5293897 to your computer and use it in GitHub Desktop.
Delete s3 bucket with minimal api calls
require 'fog'
bucket = 'bucket-name'
credentials = {
:provider => 'AWS',
:aws_access_key_id => 'access_key_id',
:aws_secret_access_key => 'secret_key',
}
fog = Fog::Storage.new(credentials)
files = fog.directories.get(bucket).files.map{ |file| file.key }
fog.delete_multiple_objects(bucket, files) unless files.empty?
fog.delete_bucket(bucket)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment