Created
June 3, 2014 04:03
-
-
Save sureshsaggar/22f1da085fe6149fe9ec to your computer and use it in GitHub Desktop.
Deleting Amazon S3 bucket using Boto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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