Using Console
Using CLI
<bucket-name>
with the name of the S3 bucket and <number-of-days>
with the number of days for which the objects should be locked.Using Python
boto3
library for this.boto3.client()
method.put_bucket_object_lock_configuration()
method of the S3 client object to enable the object lock feature for your S3 bucket. This method takes the following parameters:Bucket
: The name of the S3 bucket for which you want to enable the object lock feature.ObjectLockConfiguration
: A dictionary that contains the configuration settings for the object lock feature. In this case, we need to set the ObjectLockEnabled
key to Enabled
.put_bucket_object_lock_configuration()
method to ensure that the object lock feature has been enabled successfully.