Skip to content

Instantly share code, notes, and snippets.

@jbcurtin
Created May 8, 2019 16:12
Show Gist options
  • Save jbcurtin/dcaacc69d1942c6c003d6b9fe990b8f0 to your computer and use it in GitHub Desktop.
Save jbcurtin/dcaacc69d1942c6c003d6b9fe990b8f0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import boto3
s3client = boto3.client('s3')
for name in [bucket['Name'] for bucket in s3client.list_buckets()['Buckets']]:
if '10two1' in name:
continue
print(f'Deleting bucket[{name}]')
bucket = boto3.resource('s3').Bucket(name=name)
for item in bucket.objects.all():
item.delete()
bucket.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment