Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2016 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/3937ca3aaceb5f83e13968a309a395dd to your computer and use it in GitHub Desktop.
Save anonymous/3937ca3aaceb5f83e13968a309a395dd to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import boto
BUCKET_NAME = "bucket-name"
DELETE_DATE = "2016-09-15"
counter = 0
bucket = boto.connect_s3().get_bucket(BUCKET_NAME)
for v in bucket.list_versions():
if (isinstance(v, boto.s3.deletemarker.DeleteMarker) and
v.is_latest and
DELETE_DATE in v.last_modified):
counter += 1
bucket.delete_key(v.name, version_id=v.version_id)
print counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment