Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Key Management Service
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Keys
    • Key version
    • Data encryption
  • Concepts
    • Overview
    • Keys
    • Key version
    • Encryption
    • Envelope encryption
    • Key consistency
    • Quotas and limits
  • Use cases
    • All use cases
    • Data encryption
      • Which encryption method should I choose?
      • Encrypting data using the Yandex.Cloud CLI and API
      • Encrypting data using the Yandex.Cloud SDK
      • Encrypting data using the AWS Encryption SDK
      • Encrypting data using Google Tink
    • Encrypting secrets in Managed Service for Kubernetes
    • KMS key management with Hashicorp Terraform
    • Encrypting secrets in Hashicorp Terraform
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • SymmetricCryptoService
      • SymmetricKeyService
      • OperationService
    • REST
      • Overview
      • SymmetricCrypto
        • Overview
        • decrypt
        • encrypt
        • generateDataKey
        • reEncrypt
      • SymmetricKey
        • Overview
        • cancelVersionDestruction
        • create
        • delete
        • get
        • list
        • listAccessBindings
        • listOperations
        • listVersions
        • rotate
        • scheduleVersionDestruction
        • setAccessBindings
        • setPrimaryVersion
        • update
        • updateAccessBindings
  • Questions and answers
  1. Step-by-step instructions
  2. Key version

Key version management

  • Make a version primary
  • Destroy a key version
  • Cancel version destruction

You can make key versions primary (the default key version is used for encryption and decryption) and destroy them. To create a new key version, rotate the key.

Make a version primary

To make a version primary:

Management console
CLI
  1. Log in to management console.
  2. Select Key Management Service.
  3. In the Keys tab, click the key in the list to open the page with its attributes.
  4. Click in the line of the desired version and select Make primary from the menu.
  1. Get a list of versions for the desired key:

    $ yc kms symmetric-key list-versions example-key
    
    +----------------------+---------+--------+-----------+
    |          ID          | PRIMARY | STATUS | ALGORITHM |
    +----------------------+---------+--------+-----------+
    | abjhduu82ao0r0tkjlp2 | true    | ACTIVE | AES_128   |
    | abj8cvn99nam26f0f4a3 | false   | ACTIVE | AES_128   |
    | abjed9ciau8eatb0pg93 | false   | ACTIVE | AES_256   |
    | abjvejjvfktqc4hsqpss | false   | ACTIVE | AES_128   |
    +----------------------+---------+--------+-----------+
    
  2. Change the key version by specifying the ID of the desired version:

    $ yc kms symmetric-key set-primary-version example-key-1 \
      --version-id abj8cvn99nam26f0f4a3
    

The next encryption or decryption request omitting the key version will use the new primary version.

Destroy a key version

You can't destroy a version immediately: you can only schedule its destruction (for the next day at least).

Alert

On the scheduled date, the key version is permanently destroyed: if you still have data encrypted with this key version, you can no longer decrypt it.

Management console
CLI

To destroy a version:

  1. Log in to management console.
  2. Select Key Management Service.
  3. In the Keys tab, click the key in the list to open the page with its attributes.
  4. Click in the line of the desired version and select Schedule destruction from the menu.

The version switches to the Scheduled For Destruction status. The day that destruction is scheduled for is shown in the Destruction date column.

To destroy a version:

  1. Get a list of versions for the desired key:

    $ yc kms symmetric-key list-versions example-key
    +----------------------+---------+--------+-----------+
    |          ID          | PRIMARY | STATUS | ALGORITHM |
    +----------------------+---------+--------+-----------+
    | abj8cvn99nam26f0f4a3 | true    | ACTIVE | AES_128   |
    | abjed9ciau8eatb0pg93 | false   | ACTIVE | AES_256   |
    | abjhduu82ao0r0tkjlp2 | false   | ACTIVE | AES_128   |
    | abjvejjvfktqc4hsqpss | false   | ACTIVE | AES_128   |
    +----------------------+---------+--------+-----------+
    
  2. Schedule the destruction of a version:

    $ yc kms symmetric-key schedule-version-destruction example-key \
      --version-id abjed9ciau8eatb0pg93
    

    The status of the version switches to SCHEDULED_FOR_DESTRUCTION and the destroy_at field shows the time when destruction is scheduled for.

Cancel version destruction

If you scheduled the destruction of a key version, you can cancel it before the scheduled date:

Management console
CLI
  1. Log in to management console.
  2. Select Key Management Service.
  3. In the Keys tab, click the key in the list to open the page with its attributes.
  4. Click in the line of the desired version and select Cancel destruction from the menu.

The version reverts to the Active status.

  1. Get a list of versions for the desired key:

    $ yc kms symmetric-key list-versions example-key
    +----------------------+---------+---------------------------+-----------+
    |          ID          | PRIMARY |          STATUS           | ALGORITHM |
    +----------------------+---------+---------------------------+-----------+
    | abj8cvn99nam26f0f4a3 | true    | ACTIVE                    | AES_128   |
    | abjed9ciau8eatb0pg93 | false   | SCHEDULED_FOR_DESTRUCTION | AES_256   |
    | abjhduu82ao0r0tkjlp2 | false   | ACTIVE                    | AES_128   |
    | abjvejjvfktqc4hsqpss | false   | ACTIVE                    | AES_128   |
    +----------------------+---------+---------------------------+-----------+
    
  2. Cancel the destruction of a version:

    $ yc kms symmetric-key cancel-version-destruction example-key \
      --version-id abjed9ciau8eatb0pg93
    

    The version reverts to the Active status.

In this article:
  • Make a version primary
  • Destroy a key version
  • Cancel version destruction
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC