Lifecycle policies manage the storage of objects so that they are stored cost-effectively. Here’s an example of how to set up a lifecycle policy:
import boto3
# Create an S3 client
s3 = boto3.client('s3')
# Enable versioning
bucket_name = 'my-bucket'
s3.put_bucket_versioning(
Bucket=bucket_name,
VersioningConfiguration={
'Status': 'Enabled'
}
)
print(f'Versioning enabled for bucket {bucket_name}')