Skip to content

Instantly share code, notes, and snippets.

@scottschreckengaust
Last active June 28, 2024 15:59
Show Gist options
  • Save scottschreckengaust/c93762c653c002681734a7bcd937d2ed to your computer and use it in GitHub Desktop.
Save scottschreckengaust/c93762c653c002681734a7bcd937d2ed to your computer and use it in GitHub Desktop.
Deletes non-empty AWS S3 buckets
#!/usr/bin/env python
"""\
Deletes non-empty AWS S3 Buckets
WARNING: VERY DESTRUCTIVE
Usage: myscript.py your_bucket_name
"""
import sys
import boto3
session = boto3.Session()
s3 = session.resource(service_name='s3')
bucket = s3.Bucket(sys.argv[1])
bucket.object_versions.delete()
bucket.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment