How Do I Use Object Locking on Files in My Object Storage?

Can I use object locking on files in my Object Storage?

You can use object locking to protect files from being deleted or overwritten. You can also make the protection last for a specific amount of time. You can find more information object locking here.


How do I enable object locking on files in my Object Storage?
The following example requires aws cli to be installed and configured.

  1. First you need to create a bucket with object locking enabled. Here is an example:
    aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api create-bucket --bucket bucket-with-locking --object-lock-enabled-for-bucket

  2. The next step consists of setting the object locking configuration. Here is an example:
    aws --profile eu2 --region default --endpoint-url https://eu2.contabostorage.com s3api put-object-lock-configuration --bucket bucket-with-locking --object-lock-configuration '{ "ObjectLockEnabled": "Enabled", "Rule": { "DefaultRetention": { "Mode": "GOVERNANCE", "Days": 3 } } }'
    This example sets the retention time for 3 days. Fore more details please refer to How S3 Object Lock works

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

Modified on Wed, 18 Sep at 11:57 AM

Can’t find what you’re looking for?

Get in Touch

Do you have a pre-sales question?