Object Lock (API)
This page describes the S3 operations that control Object Lock on chili. For the basics, such as governance mode, legal hold and setup, see Object Lock (WORM).
You enable Object Lock only when you create the bucket in the chili Console. An existing bucket without Object Lock cannot be switched over later through the API. With Object Lock, versioning is always on.
All examples use path style, the endpoint https://s3-ch-east.chilistorage.com and governance mode, which every account can use without activation. chili support enables compliance mode once for your account.
Operations
Operation | Method and path | Notes |
|---|---|---|
PutObjectLockConfiguration |
| Set default retention, |
GetObjectLockConfiguration |
| Read the configuration |
PutObjectRetention |
| Period per version, |
GetObjectRetention |
|
|
PutObjectLegalHold |
|
|
GetObjectLegalHold |
|
|
DeleteObject |
| Locked versions: |
Operations in detail
PutObjectLockConfiguration
Sets or changes the default retention of a bucket with Object Lock enabled. chili then locks every newly written object version automatically for the given period.
PUT /my-worm-bucket?object-lock HTTP/1.1
Host: s3-ch-east.chilistorage.com
Content-MD5: <Base64 MD5 of the body>Content-MD5is required. The AWS CLI and common SDKs calculate the header themselves.ObjectLockEnabledalways has the valueEnabled.DefaultRetentioncontainsModeand eitherDaysorYears, not both.- Without
Rulethere is no default retention. The application then sets the period per object version, which is what Veeam expects.
<ObjectLockConfiguration>
<ObjectLockEnabled>Enabled</ObjectLockEnabled>
<Rule>
<DefaultRetention>
<Mode>GOVERNANCE</Mode>
<Days>30</Days>
</DefaultRetention>
</Rule>
</ObjectLockConfiguration>aws s3api put-object-lock-configuration \
--bucket my-worm-bucket \
--object-lock-configuration '{"ObjectLockEnabled":"Enabled","Rule":{"DefaultRetention":{"Mode":"GOVERNANCE","Days":30}}}' \
--endpoint-url https://s3-ch-east.chilistorage.comThe default retention applies only to new object versions. Versions already stored keep their existing period.
GetObjectLockConfiguration
Reads the Object Lock configuration of a bucket.
GET /my-worm-bucket?object-lock HTTP/1.1
Host: s3-ch-east.chilistorage.com<ObjectLockConfiguration>
<ObjectLockEnabled>Enabled</ObjectLockEnabled>
<Rule>
<DefaultRetention>
<Mode>GOVERNANCE</Mode>
<Days>30</Days>
</DefaultRetention>
</Rule>
</ObjectLockConfiguration>aws s3api get-object-lock-configuration \
--bucket my-worm-bucket \
--endpoint-url https://s3-ch-east.chilistorage.comIf the bucket has no Object Lock configuration, chili responds with ObjectLockConfigurationNotFoundError.
PutObjectRetention
Sets mode and expiry date for a single object version. This is how backup software such as Veeam works.
PUT /my-worm-bucket/report.pdf?retention&versionId=<VERSION_ID> HTTP/1.1
Host: s3-ch-east.chilistorage.comversionIdis required on chili. You get the version ID in the PutObject response (headerx-amz-version-id) or through ListObjectVersions.RetainUntilDatein ISO 8601 format, for example2027-12-31T00:00:00Z.- You can extend a period at any time. In governance mode, shortening or removing it requires
x-amz-bypass-governance-retention: trueand thes3:BypassGovernanceRetentionpermission.
<Retention>
<Mode>GOVERNANCE</Mode>
<RetainUntilDate>2027-12-31T00:00:00Z</RetainUntilDate>
</Retention>aws s3api put-object-retention \
--bucket my-worm-bucket --key report.pdf \
--version-id <VERSION_ID> \
--retention '{"Mode":"GOVERNANCE","RetainUntilDate":"2027-12-31T00:00:00Z"}' \
--endpoint-url https://s3-ch-east.chilistorage.comGetObjectRetention
Reads mode and expiry date of an object version.
GET /my-worm-bucket/report.pdf?retention&versionId=<VERSION_ID> HTTP/1.1
Host: s3-ch-east.chilistorage.com<Retention>
<Mode>GOVERNANCE</Mode>
<RetainUntilDate>2027-12-31T00:00:00.000Z</RetainUntilDate>
</Retention>aws s3api get-object-retention \
--bucket my-worm-bucket --key report.pdf \
--version-id <VERSION_ID> \
--endpoint-url https://s3-ch-east.chilistorage.comPutObjectLegalHold
Sets or removes a legal hold on an object version. A legal hold has no expiry date and applies independently of any retention period.
PUT /my-worm-bucket/report.pdf?legal-hold&versionId=<VERSION_ID> HTTP/1.1
Host: s3-ch-east.chilistorage.comversionIdis required.StatusisONorOFF.
<LegalHold>
<Status>ON</Status>
</LegalHold>aws s3api put-object-legal-hold \
--bucket my-worm-bucket --key report.pdf \
--version-id <VERSION_ID> --legal-hold Status=ON \
--endpoint-url https://s3-ch-east.chilistorage.comGetObjectLegalHold
Reads the legal hold status of an object version.
GET /my-worm-bucket/report.pdf?legal-hold&versionId=<VERSION_ID> HTTP/1.1
Host: s3-ch-east.chilistorage.com<LegalHold>
<Status>ON</Status>
</LegalHold>aws s3api get-object-legal-hold \
--bucket my-worm-bucket --key report.pdf \
--version-id <VERSION_ID> \
--endpoint-url https://s3-ch-east.chilistorage.comSetting the lock on upload
The S3 standard allows you to pass mode, period and legal hold directly with PutObject:
Header | Value |
|---|---|
|
|
| Date in ISO 8601 format |
|
|
Applications such as Veeam usually set the period after the upload with PutObjectRetention. On chili this is the most reliable approach. If you build your own application, we recommend the same approach or a default retention on the bucket.
Bypassing a governance lock
The header x-amz-bypass-governance-retention: true bypasses a governance lock, for example to delete a version early or to shorten a period. The access keys need the s3:BypassGovernanceRetention permission. The header does not bypass a legal hold.
aws s3api delete-object \
--bucket my-worm-bucket --key report.pdf \
--version-id <VERSION_ID> \
--bypass-governance-retention \
--endpoint-url https://s3-ch-east.chilistorage.comGive backup software and applications keys without s3:BypassGovernanceRetention. You assign permissions in the chili Console under IAM & object access.
Deleting locked versions
Request | Result |
|---|---|
DeleteObject without | chili sets a delete marker, the locked version is kept |
DeleteObject with the |
|
DeleteObject with |
|
DeleteObject with | Version is deleted (governance mode only) |
Lifecycle rules never delete locked versions.
Next
- Object Lock (WORM): concept and setup
- Versioning: version IDs and delete markers
- Access & CORS: permissions via bucket policy
- Error codes:
AccessDeniedand other errors