简体   繁体   中英

aws cloudformation snippet for S3 Bucket to apply LifecycleConfiguration to delete all existing versions

The lifecycle configuration yaml template snippet must delete all existing previous versions as well as current versions from now on. The versioning is suspended for this bucket. Any help is highly appreciated.

Using Boto3:

#!/usr/bin/env python

import boto3


s3 = boto3.resource('s3')
bucket = s3.Bucket('your-bucket-name')
bucket.object_versions.all().delete()

You can do it on GUI too but that would take lots of time if you have lots of files.

You can find further possible ways here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM