How do I delete a versioned bucket in AWS S3 using the CLI?

前端 未结 20 976
我在风中等你
我在风中等你 2020-12-07 16:34

I have tried both s3cmd:

$ s3cmd -r -f -v del s3://my-versioned-bucket/

And the AWS CLI:

$ aws s3 rm s3://my-v         


        
20条回答
  •  情话喂你
    2020-12-07 17:12

    Using boto3 it's even easier than with the proposed boto solution to delete all object versions in an S3 bucket:

    #!/usr/bin/env python
    import boto3
    
    s3 = boto3.resource('s3')
    bucket = s3.Bucket('your-bucket-name')
    bucket.object_versions.all().delete()
    

    Works fine also for very large amounts of object versions, although it might take some time in that case.

提交回复
热议问题