Skip to content

Instantly share code, notes, and snippets.

@TJC
Created April 20, 2018 06:05
Show Gist options
  • Select an option

  • Save TJC/2586dea8b99085c9df7a8bc4f4cc968f to your computer and use it in GitHub Desktop.

Select an option

Save TJC/2586dea8b99085c9df7a8bc4f4cc968f to your computer and use it in GitHub Desktop.
Empty and remove an S3 bucket containing versioned file tombstones
#!/usr/bin/env python
# This took several days to run, but worked. Unlike the lifecycle rules I'd tried to use instead.
import boto3
session = boto3.Session()
s3 = session.resource(service_name='s3')
bucket = s3.Bucket('your-bucket-name')
bucket.object_versions.delete()
bucket.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment