Versioning is used to keep multiple variants of an object in the same bucket. You can enable versioning using the AWS Management Console, AWS CLI, or AWS SDKs. Here’s an example using Python's boto3:
import boto3
# Initialize a session using Amazon S3
s3 = boto3.client('s3')
# Enable versioning on the bucket
bucket_name = 'my-unique-bucket-name'
response = s3.put_bucket_versioning(
Bucket=bucket_name,
VersioningConfiguration={
'Status': 'Enabled'
}
)
print(response)