VK Cloud logo

Configuring storage for regulatory compliance

VK Object Storage allows you to protect objects by locking them against deletion or overwriting (Object Lock). Use object locking for critical data (for example, personal data) that, according to regulatory or legal requirements, must be stored in an immutable form for specified periods followed by destruction. This helps ensure auditability 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. Configure the default retention policy for the bucket

Set a temporary lock for the bucket in strict mode (COMPLIANCE) and specify the exact data retention period:

aws s3api put-object-lock-configuration \  --bucket <BUCKET_NAME> \  --object-lock-configuration '{    "ObjectLockEnabled": "Enabled",    "Rule": {      "DefaultRetention": {        "Mode": "<LOCK_MODE>",        "Days": <RETENTION_PERIOD>      }    }  }' \  --endpoint-url <ENDPOINT_URL>

Here:

  • <BUCKET_NAME> — name of the bucket.

  • <LOCK_MODE> — lock mode:

  • <RETENTION_PERIOD> — the lock period in days (Days) or years (Years) from the moment the object is uploaded. You cannot specify Days and Years at the same time. Example: 1825 days (5 years).

  • <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. (Optional) Set an individual retention period for an object

An individual retention period can be set for objects that belong to different categories and have different retention periods.

Set the lock when uploading the object:

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.

4. Check the lock status

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.

5. (Optional) Set an indefinite lock

Upon receiving an official request to retain data for an indefinite period, use an indefinite lock (legal hold). It takes precedence over any retention periods and indefinitely prohibits deletion or modification of the object until it is explicitly removed.

  1. Set the lock:

    aws s3api put-object-legal-hold \  --bucket <BUCKET_NAME> \  --key <OBJECT_KEY> \  --legal-hold Status=ON \  --endpoint-url <ENDPOINT_URL>

    Here:

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

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

    • <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. Check the lock status:

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

    Here:

    • <BUCKET_NAME> — name of the bucket.

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

    • <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.
Was this article helpful?