VK Cloud logo

Protecting critical data

VK Object Storage allows you to protect objects by locking them against deletion or overwriting (Object Lock). Use object locking for critical data, such as backups or data that must be kept immutable for specified periods to ensure audit and legal validity.

Preparation steps

Make sure that you have installed and configured AWS CLI.

1. Prepare a bucket

  1. Create a new bucket:

    aws s3api create-bucket \    --bucket <BUCKET_NAME> \    --endpoint-url <ENDPOINT_URL>

    Here:

    • <BUCKET_NAME> — name of the bucket, matching the recommended rules.

      Once the bucket is created, its name cannot be changed.

    • <ENDPOINT_URL> — the VK Object Storage service domain, must match the account region:

      • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — Kazakhstan region domain.
  2. Enable versioning:

    aws s3api put-bucket-versioning \  --bucket <BUCKET_NAME> \  --versioning-configuration Status=Enabled \  --endpoint-url <ENDPOINT_URL>

    Here:

    • <BUCKET_NAME> — name of the bucket.

    • <ENDPOINT_URL> — the VK Object Storage service domain, must match the account region:

      • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — Moscow region domain;
      • https://hb.kz-ast.vkcloud-storage.ru — Kazakhstan region domain.
  3. Enable object locking:

    aws s3api put-object-lock-configuration \  --bucket <BUCKET_NAME> \  --object-lock-configuration '{    "ObjectLockEnabled": "Enabled"    }' \  --endpoint-url <ENDPOINT_URL>

    Here:

    • <BUCKET_NAME> — name of the bucket.

    • <ENDPOINT_URL> — must match the account region:

      • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — for the Moscow region;
      • https://hb.kz-ast.vkcloud-storage.ru — for the Kazakhstan region.

2. Upload an object and apply a lock to it

  1. Create an object:

    echo "CRITICAL_DATA" > <OBJECT_NAME> \gzip <OBJECT_NAME>
  2. Upload the object with a temporary lock applied in strict mode (COMPLIANCE):

    aws s3api put-object \  --body <PATH> \  --bucket <BUCKET_NAME> \  --key <OBJECT_KEY> \  --object-lock-mode COMPLIANCE \  --object-lock-retain-until-date "<RETENTION_PERIOD>" \  --endpoint-url <ENDPOINT_URL>

    Here:

    • <PATH> — path to the directory containing the objects whose retention period needs to be changed.

    • <BUCKET_NAME> — name of the bucket.

    • <OBJECT_KEY> — full name of the object, including its path.

    • <RETENTION_PERIOD> — date and time when the lock expires, in ISO 8601 format. Example: 2030-01-01T00:00:00.000Z.

    • <ENDPOINT_URL> — must match the account region:

      • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — for the Moscow region;
      • https://hb.kz-ast.vkcloud-storage.ru — for the Kazakhstan region.

3. Make sure the lock is applied

To find out the temporary lock status of an object, run the command:

aws s3api get-object-retention \  --bucket <BUCKET_NAME> \  --key <OBJECT_KEY> \  --endpoint-url <ENDPOINT_URL>

Here:

  • <BUCKET_NAME> — name of the bucket that contains the desired object.

  • <OBJECT_KEY> — name of the object and its path, including directories, if any.

  • <ENDPOINT_URL> — must match the account region:

    • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — for the Moscow region;
    • https://hb.kz-ast.vkcloud-storage.ru — for the Kazakhstan region.

The response should contain a JSON structure confirming the lock mode and expiration date.

4. Make sure the object cannot be deleted

Try to delete the object:

aws s3api delete-object \   --bucket <BUCKET_NAME> \   --key <OBJECT_KEY> \   --version-id <VERSION_ID> \   --endpoint-url <ENDPOINT_URL>

Here:

  • <BUCKET_NAME> — name of the bucket where the object is located.

  • <OBJECT_KEY> — full name of the object, including its path.

  • <VERSION_ID> — version identifier of the object in a bucket with versioning.

  • <ENDPOINT_URL> — must match the account region:

    • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — for the Moscow region;
    • https://hb.kz-ast.vkcloud-storage.ru — for the Kazakhstan region.

The response should be an Access Denied error. This confirms that the WORM protection is active.

5. Check access to the object

Download the object:

aws s3api get-object \  --bucket <BUCKET_NAME> \  --key <OBJECT_KEY> \  --version-id <VERSION_ID> \  <FILE_NAME> \  --endpoint-url <ENDPOINT_URL>

Here:

  • <BUCKET_NAME> — name of the bucket that contains the desired object.

  • <OBJECT_KEY> — name of the object and its path, including directories, if any.

  • <VERSION_ID> — version identifier of the object in a bucket with versioning. If the --version-id parameter is not specified, the current version will be used.

  • <FILE_NAME> — the name that will be assigned to the downloaded file.

  • <ENDPOINT_URL> — must match the account region:

    • https://hb.vkcloud-storage.ru or https://hb.ru-msk.vkcloud-storage.ru — for the Moscow region;
    • https://hb.kz-ast.vkcloud-storage.ru — for the Kazakhstan region.

The object remains available for reading and downloading, which allows you to use it for recovery.

Was this article helpful?