Object Lock
Object Lock uses the WORM (Write Once Read Many) principle and allows you to lock objects to prevent them from being overwritten or deleted.
To use Object Lock, the bucket must have versioning enabled. Object lock applies only to object versions.
Locking can be of different types and modes. Depending on the lock type, it can be set on individual objects or on a bucket by default — the lock will apply to new objects.
The ability to manage locks also depends on the user role and bucket policy rules; for details, see the Manage access to S3 manual. You can work with Object Lock in the control panel (capabilities are limited), via the S3 API, and via tools that use it, such as the AWS CLI.
To manage object locking after configuring Object Lock, use the Manage object locking manual.
If you delete a project that contains locked objects, they will not be deleted while the lock is active. However, they will not be displayed in the control panel and via the API. To restore locked objects after deleting a project, submit a ticket.
Types and retention modes
Locking can be temporary or indefinite. Temporary locking has two modes: Governance and Compliance.
If both a temporary and an indefinite lock are enabled for an object, the indefinite lock takes precedence.
* Available only to users:
- with the
memberrole; - with other roles with access to S3 if the bucket has an access policy that allows the action
s3:BypassGovernance.
Enable Object Lock in a bucket
The following users can enable Object Lock:
- Account Owner;
- users with the
member,s3.admin, andobject_storage:adminroles; - users with the
s3.bucket.user,s3.user, andobject_storage_userroles if the access policy allows them the actions3:PutBucketObjectLockConfiguration.
Once you have enabled Object Lock, you cannot disable it or suspend versioning.
Enabling Object Lock does not lock objects automatically. After configuring Object Lock in a bucket, you can:
- manage object locks;
- upload objects with an active lock immediately (only via the S3 API and tools that use it);
- manage default bucket retention.
Control panel
AWS CLI
If versioning is disabled or suspended in the bucket, it will be enabled automatically when Object Lock is enabled.
-
In the control panel, in the top menu, click Products and select S3.
-
Go to the Buckets section.
-
Open the bucket page → Configuration tab.
-
In the Data protection block, on the Object Lock line, click Edit.
-
Select the Enable Object Lock checkbox.
-
Optional: enable default bucket retention:
6.1. Select the Enable default retention checkbox.
6.2. Select a lock mode.
6.3. Specify the retention period. Maximum retention period:
- for Compliance mode — one year. To set a Compliance lock for more than a year, use the API or tools such as the AWS CLI;
- for Governance mode — 100 years.
You can manage default retention even after enabling Object Lock.
-
Click Save.
Manage default bucket retention
The following users can manage default retention:
- Account Owner;
- users with the
member,s3.admin, andobject_storage:adminroles; - users with the
s3.bucket.user,s3.user, andobject_storage_userroles if the access policy allows them the corresponding actions.
Check default retention
The presence of default retention means that after it was enabled, all new objects were locked upon upload. However, the bucket may contain unlocked objects — those uploaded:
- before the lock was enabled in the bucket;
- after the lock was enabled in the bucket and were immediately locked, but their retention period has expired.
To check retention on a specific object, refer to the Check retention section of the Manage object locks instructions.
Control panel
AWS CLI
- In the control panel, in the top menu, click Products and select S3.
- Go to the Buckets section.
- Open the bucket page → Configuration tab.
- In the Data protection block, on the Object Lock line, check the information about the status, mode, and duration of the default retention.
Enable default retention
Retention will apply to all new objects in the bucket. Previously uploaded objects will not be locked. To lock already uploaded objects, refer to the Enable retention section of the Manage object lock instructions.
Control panel
AWS CLI
-
In the control panel, in the top menu, click Products and select S3.
-
Go to the Buckets section.
-
Open the bucket page → Configuration tab.
-
In the Data protection block, on the Object Lock line, click Edit.
-
Make sure that the Enable Object Lock checkbox is selected.
-
Select the Enable default retention checkbox.
-
Select a lock mode.
-
Specify the retention period. Maximum retention period:
- for Compliance mode — one year. To set a Compliance lock for more than a year, use the API or tools such as the AWS CLI;
- for Governance mode — 100 years.
-
Click Save.
Change default retention period
The modified retention period will apply to all new objects in the bucket. The retention period for previously uploaded objects will remain unchanged. To change the retention period of already uploaded objects, refer to the Change retention period section of the Manage object lock instructions.
Control panel
AWS CLI
-
In the control panel, in the top menu, click Products and select S3.
-
Go to the Buckets section.
-
Open the bucket page → Configuration tab.
-
In the Data protection block, on the Object Lock line, click Edit.
-
Specify a new retention period. Maximum retention period:
- for Compliance mode — one year. To set a Compliance lock for more than a year, use the API or tools such as the AWS CLI;
- for Governance mode — 100 years.
-
Click Save.
Change default retention mode
The modified retention mode will apply to all new objects in the bucket. The retention mode of previously uploaded objects will remain unchanged. To change the retention mode of already uploaded objects, refer to the Change retention mode section of the Manage object lock instructions.
Control panel
AWS CLI
-
In the control panel, in the top menu, click Products and select S3.
-
Go to the Buckets section.
-
Open the bucket page → Configuration tab.
-
In the Data protection block, on the Object Lock line, click Edit.
-
Select the Compliance lock mode.
-
Select a new lock mode.
-
Specify the retention period. Maximum retention period:
- for Compliance mode — one year. To set a Compliance lock for more than a year, use the API or tools such as the AWS CLI;
- for Governance mode — 100 years.
-
Click Save.
Disable default retention
After disabling default retention, new objects will not be locked, but Object Lock will remain enabled on the bucket — it cannot be disabled.
Objects that were uploaded and automatically locked before disabling default retention will remain locked according to the lock mode. To disable retention in Governance mode for already uploaded objects, refer to the Disable retention section of the Manage object lock instructions.
Control panel
AWS CLI
Temporary lock can be disabled in the Control Panel only by the Account Owner or a user with the member role.
- In the control panel, in the top menu, click Products and select S3.
- Go to the Buckets section.
- Open the bucket page → Configuration tab.
- In the Data protection block, on the Object Lock line, click Edit.
- Clear the Enable default retention checkbox.
- Click Save.