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

Details…

Scroll to Top