Skip to content

Instantly share code, notes, and snippets.

@oussemos
Created March 20, 2018 13:11
Show Gist options
  • Save oussemos/03970c94bc4b75f1088f8e4a0af93dac to your computer and use it in GitHub Desktop.
Save oussemos/03970c94bc4b75f1088f8e4a0af93dac to your computer and use it in GitHub Desktop.
Delete bucket S3 all version with boto3
import boto3
wired_buckets = [
'bucket',
]
s3 = boto3.resource('s3')
for wired_bucket in wired_buckets:
print wired_bucket
bucket = s3.Bucket(wired_bucket)
try:
bucket.object_versions.delete()
except:
print 'bucket does not exist'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment