You can send requests by S3 API to do the tasks described below for configuring and viewing object locking configurations on buckets and objects.
Bucket Operations
You can manage object lock configuration on buckets using the following API requests and headers. The operations require user permissions which must be granted through identity policies.
Task | S3 API Operation | S3 Permission Required |
|---|---|---|
Enable object locking on a new bucket.
| Include the
| s3:PutBucketObjectLockConfiguration |
Enable object locking on an existing bucket and set a default retention period | s3:PutBucketObjectLockConfiguration | |
Get the Object Lock configuration of a bucket | s3:GetObjectLockConfiguration |
Object Operations
Task | S3 API Operations | Notes | S3 Permission Required |
|---|---|---|---|
Retention Period Tasks | |||
Set a retention configuration on an object. | PutObjectRetention | This includes setting the retention mode and setting an explicit retention period on the object. The explicit retention period overrides a default retention period set on the bucket. | s3:PutObjectRetention |
Extend a retention period after setting a retention configuration on an object version. | To do this, submit a new lock request for the object version with a | s3:PutObjectRetention | |
Get the retention settings of an object. | This includes the date and time and the retention mode. | s3:GetObjectRetention | |
Get the date and time when an object's lock is due to expire, along with other object information. | GetObject, HeadObject | The response includes the | s3:GetObjectRetention |
Get an object's retention mode, along with other object information. | GetObject, HeadObject | The response includes the Compliance mode is not supported. Therefore, object lock mode is always | s3:GetObjectRetention |
Legal Hold Tasks | |||
Apply a legal hold configuration to an object. | PutObjectLegalHold | Placing a legal hold on an object version doesn't affect the retention mode or retention period for that object version. | s3:PutObjectLegalHold |
Get an object's current legal hold status. | GetObjectLegalHold, GetObject | The With | s3:GetObjectLegalHold |
Operations that Require Bypassing Governance Mode | |||
Overwrite or delete an object version or alter its lock settings, including shortening the retention period, and removing an object lock by placing a new lock with empty parameters. | You must explicitly include | s3:BypassGovernanceRetention | |