Skip to content

Instantly share code, notes, and snippets.

@rabidpraxis
Created April 2, 2013 16:53
Show Gist options
  • Save rabidpraxis/5293897 to your computer and use it in GitHub Desktop.
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