Created
May 7, 2019 05:02
-
-
Save anuragmathur1/31f08410ff4ffd4de34fc37da0ca25f8 to your computer and use it in GitHub Desktop.
You can not use cli to delete all versions of an object in a bucket. That will prevent you from removing the bucket as well. The below 4 lines will delete all versions of all all objects in the given s3 bucket.
This file contains 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 | |
import boto3 | |
s3 = boto3.resource('s3') | |
bucket = s3.Bucket('<<Bucket-name-here>>') | |
bucket.object_versions.all().delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment