Skip to content

Instantly share code, notes, and snippets.

@yue4u
Last active September 10, 2022 11:54
Show Gist options
  • Save yue4u/bda7b7c5e7352dc8e33862abc308019a to your computer and use it in GitHub Desktop.
Save yue4u/bda7b7c5e7352dc8e33862abc308019a to your computer and use it in GitHub Desktop.
I tried and searched a lot but still failed to delete a s3 bucket, here is the finial answer.
#!/usr/bin/env python3
import boto3
bucket_name = ''
bucket = s3.Bucket(bucket_name)
s3 = boto3.resource('s3')
print('deleting ....')
bucket.object_versions.all().delete()
bucket.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment