Skip to content

Instantly share code, notes, and snippets.

@tzangms
Created April 30, 2014 06:32
Show Gist options
  • Select an option

  • Save tzangms/92d3fe8aa1b9238642e9 to your computer and use it in GitHub Desktop.

Select an option

Save tzangms/92d3fe8aa1b9238642e9 to your computer and use it in GitHub Desktop.
"""
Delete S3 bucket with contents, with S3 Multi-Object Delete.
This script makes you delete S3 bucket quickly.
Before using this script, please install boto
$ pip install boto
and setup ~/.boto config
[Credentials]
aws_access_key_id = <your-access-key>
aws_secret_access_key = <your-secret-key>
"""
from boto.s3.connection import S3Connection
conn = S3Connection()
bucket = conn.get_bucket('<bucket-name>')
while True:
result = bucket.delete_keys(bucket.get_all_keys())
if not result.deleted:
break
print 'Continue ...'
bucket.delete()
print 'Done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment