Skip to content

Instantly share code, notes, and snippets.

@guyzyl
Created September 20, 2023 07:08
Show Gist options
  • Save guyzyl/778fede6f85ebf651a9f2285e24e8868 to your computer and use it in GitHub Desktop.
Save guyzyl/778fede6f85ebf651a9f2285e24e8868 to your computer and use it in GitHub Desktop.
Delete all files in an S3 bucket including file versions
import boto3
BUCKET_NAME = "my-bucket"
s3 = boto3.resource("s3")
bucket = s3.Bucket(BUCKET_NAME)
bucket.objects.delete()
bucket.object_versions.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment