Skip to content

Instantly share code, notes, and snippets.

Created June 3, 2014 04:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sureshsaggar/22f1da085fe6149fe9ec to your computer and use it in GitHub Desktop.
Deleting Amazon S3 bucket using Boto
import boto
from boto.s3.connection import OrdinaryCallingFormat
(aws_access_key_id, aws_secret_access_key) = ('<aws_access_key_id>', '<aws_secret_access_key>')
def deleteBucket(aws_access_key_id, aws_secret_access_key, bname):
s3 = boto.connect_s3(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, calling_format=OrdinaryCallingFormat())
print '# Permanently deleting bucket[%s]...' %bname
bucket = s3.get_bucket(bname)
bucketListResultSet = bucket.list()
return bucket.delete_keys([ for key in bucketListResultSet])
deleteBucket(aws_access_key_id, aws_secret_access_key, 'my-test-bucket-name')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment