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

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

With Object Locking you can protect files from being deleted or overwritten. You can also make the protection last for a specific amount of time. Please refer to Using S3 Object Lock for a guide on tis.

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

  1. A bucket needs to support Object Locking. By default a bucket does not support it. Thus the first step is to create a bucket with object locking enabled. Here an example:
    aws --profile eu2 --region default --endpoint-url s3api create-bucket --bucket bucket-with-locking --object-lock-enabled-for-bucket
    As you might noticed the option --object-lock-enabled-for-bucket is the relevant part.

  2. The next step consists of setting the object locking configuration. Here an example:
    aws --profile eu2 --region default --endpoint-url 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 17 May 2024

Can’t find what you’re looking for?

Get in Touch

Do you have a pre-sales question?