Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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([key.name 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