Last active
June 28, 2024 15:59
-
-
Save scottschreckengaust/c93762c653c002681734a7bcd937d2ed to your computer and use it in GitHub Desktop.
Deletes non-empty AWS S3 buckets
This file contains hidden or 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
#!/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