VK Cloud logo

Object lifecycle in a bucket

VK Object Storage allows you to configure the lifecycle of objects in a bucket. A lifecycle is the automated deletion of objects from a bucket according to specified rules.

Viewing the lifecycle rules configuration

  1. Go to the VK Cloud management console.

  2. Select the project that contains the desired bucket.

  3. Go to the Object Storage → Buckets section.

  4. Open the bucket settings in one of the following ways:

    • Click  for the desired bucket and select Settings.
    • Click the name of the desired bucket, then on the bucket page click the  button.
  5. Go to the Lifecycle tab.

Adding lifecycle rules

  1. Go to the VK Cloud management console.

  2. Select the project that contains the desired bucket.

  3. Go to the Object Storage → Buckets section.

  4. Open the bucket settings in one of the following ways:

    • Click  for the desired bucket and select Settings.
    • Click the name of the desired bucket, then on the bucket page click the  button.
  5. Go to the Lifecycle tab.

  6. Click the Add rule button or plus-icon Add new rule, if the bucket already has added rules.

  7. Set the rule parameters:

    • Rule name: only digits, Latin letters, and the characters -, _, . are allowed. The name must be unique within the bucket.
    • Object key prefix: the rule will be applied only to objects with the specified prefix keys. The filter can contain only one key. Examples of prefix keys: image/, pre/, image/photo.
    • Delete data after a specified number of days: specify the number of days after which the objects will be deleted.
    • Activate the rule: disable the option if the rule being added should not currently be applied to objects.
  8. Click the Add rule button.

Editing lifecycle rules

  1. Go to the VK Cloud management console.

  2. Select the project that contains the desired bucket.

  3. Go to the Object Storage → Buckets section.

  4. Open the bucket settings in one of the following ways:

    • Click  for the desired bucket and select Settings.
    • Click the name of the desired bucket, then on the bucket page click the  button.
  5. Go to the Lifecycle tab.

  6. Click the pencil-icon icon for the rule you want to edit.

  7. Edit the rule parameters.

  8. Click the Save button.

Disabling lifecycle rules

To prevent objects from being deleted according to a specified rule, disable it:

  1. Go to the VK Cloud management console.

  2. Select the project that contains the desired bucket.

  3. Go to the Object Storage → Buckets section.

  4. Open the bucket settings in one of the following ways:

    • Click  for the desired bucket and select Settings.
    • Click the name of the desired bucket, then on the bucket page click the  button.
  5. Go to the Lifecycle tab.

  6. Disable the desired rule on the right.

Deleting lifecycle rules

  1. Go to the VK Cloud management console.

  2. Select the project that contains the desired bucket.

  3. Go to the Object Storage → Buckets section.

  4. Open the bucket settings in one of the following ways:

    • Click  for the desired bucket and select Settings.
    • Click the name of the desired bucket, then on the bucket page click the  button.
  5. Go to the Lifecycle tab.

  6. Click the trash-icon icon for the rule you want to delete.

  7. Confirm the deletion.

Setting the lifecycle rules configuration

  1. Install and configure AWS CLI, if it is not installed yet.

  2. Prepare a file in JSON format with the lifecycle rules configuration.

  3. Open the console and run the command:

    aws s3api put-bucket-lifecycle-configuration --bucket <BUCKET_NAME> --lifecycle-configuration file://<FILE_NAME>.json --endpoint-url <ENDPOINT_URL>

    Where:

    • <BUCKET_NAME> — the name of the bucket to which you want to add the rules configuration.

    • <FILE_NAME> — the name of the file with the lifecycle rules configuration.

    • <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.

Deleting the lifecycle rules configuration

  1. Install and configure AWS CLI, if it is not installed yet.

  2. Run the command in the console:

    aws s3api delete-bucket-lifecycle --bucket <BUCKET_NAME> --endpoint-url <ENDPOINT_URL>

    Where:

    • <BUCKET_NAME> — the name of the bucket whose rules configuration you want to delete.

    • <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?