import boto3
import time
s3 = boto3.resource('s3', region_name='cn-xxxxxx-1')
def set_lifecycle_30days_expiration(bucketname,prefix,rule_name):
json ={
'Rules': [
{
'Expiration': {
'Days': 30
},
'Prefix': prefix,
'Status': 'Enabled',
'ID': rule_name,
'NoncurrentVersionExpiration': {
'NoncurrentDays': 30
},
'AbortIncompleteMultipartUpload': {
'DaysAfterInitiation': 30
}
}
]
}
bucket_lifecycle = s3.BucketLifecycle(bucketname)
print(json)
response = bucket_lifecycle.put(