Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML Services
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Compute Cloud
    • All guides
      • Updating a disk
      • Configuring disk snapshot schedules
      • Moving a disk to a different folder
      • Moving a disk to a different availability zone
      • Encrypting a disk
      • Getting disk info
      • Configuring disk access permissions
      • Deleting a disk
    • Viewing service resource operations
    • Viewing metrics in Monitoring
  • Yandex Container Solution
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  1. Step-by-step guides
  2. Managing a disk
  3. Encrypting a disk

Encrypting a disk

Written by
Yandex Cloud
Improved by
Danila N.
Updated at October 20, 2025

To create an encrypted disk, you need the kms.keys.user role or higher.

If you deactivate the key used to encrypt a disk, image, or snapshot, access to the data will be suspended until you reactivate the key.

Alert

If you destroy the key or its version used to encrypt a disk, image, or snapshot, you will irrevocably lose access to the data. For details, see Destroying key versions.

Management console
CLI
Terraform
API
  1. Create a Yandex Key Management Service encryption key. For more information, see Encryption in Compute Cloud.

  2. Create an image of the disk you want to encrypt.

  3. Create an encrypted disk from the image:

    1. In the management console, select the folder where you want to create an encrypted disk.

    2. Select Compute Cloud.

    3. In the left-hand panel, select Disks.

    4. Click Create disk.

    5. Enter a name for the disk.

      • It must be from 2 to 63 characters long.
      • It can only contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    6. Select the same availability zone that contained the source disk.

    7. Set the disk parameters, such as disk type, block size, and disk size.

    8. In the Contents field, select Image and then select the image you created earlier from the list below. Use the filter to find the image.

    9. Under Encryption, enable Encrypted disk and select the key you created earlier in the KMS key field.

    10. Click Create disk.

    Once created, the disk will get the Creating status. Wait until the disk status changes to Ready before using it.

  4. Delete the image.

  5. Delete the unencrypted disk.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

  1. Create a Yandex Key Management Service encryption key:

    yc kms symmetric-key create \
      --name <key_name> \
      --default-algorithm aes-256 \
      --rotation-period 24h \
      --deletion-protection
    

    Where --name is the name of the new Key Management Service key.

    Result:

    id: abj73fd9mekk********
    folder_id: b1geoelk7fld********
    created_at: "2025-05-20T17:27:35Z"
    name: my-key1
    status: ACTIVE
    primary_version:
      id: abjdno4pqi67********
      key_id: abj73fd9mekk********
      status: ACTIVE
      algorithm: AES_256
      created_at: "2025-05-20T17:27:35Z"
      primary: true
    default_algorithm: AES_256
    rotation_period: 86400s
    deletion_protection: true
    
  2. Get a list of all disks in the default folder:

    yc compute disk list
    

    Result:

    +----------------------+--------------+-------------+---------------+--------+----------------------+-------------------------+
    |          ID          |     NAME     |    SIZE     |     ZONE      | STATUS |     INSTANCE IDS     |       DESCRIPTION       |
    +----------------------+--------------+-------------+---------------+--------+----------------------+-------------------------+
    | a7lqgbt0bb9s******** | first-disk   | 20401094656 | ru-central1-a | READY  | a7lcvu28njbh******** |                         |
    | a7lv5j5hm1p1******** | second-disk  | 21474836480 | ru-central1-a | READY  |                      |                         |
    +----------------------+--------------+-------------+---------------+--------+----------------------+-------------------------+
    
  3. Create an image of the disk you want to encrypt.

    yc compute image create \
      --name <image_name> \
      --source-disk-name <unencrypted_disk_name>
    

    Where:

    • --name: Name of the image you are creating.
    • --source-disk-name: Name of the unencrypted disk you are creating the image for.

    Result:

    done (9s)
    id: fd8lb5jnr2m2********
    folder_id: b1geoelk7fld********
    created_at: "2025-05-20T17:30:33Z"
    name: fromcli
    min_disk_size: "21474836480"
    status: READY
    os:
      type: LINUX
    hardware_generation:
      legacy_features:
        pci_topology: PCI_TOPOLOGY_V1
    
  4. Create an encrypted disk from the image:

    yc compute disk create <encrypted_disk_name> \
      --source-image-name <image_name> \
      --kms-key-name <key_name>
    

    Where:

    • --source-image-name: Image name to create an encrypted disk.
    • --kms-key-name: Encryption key name.

    Result:

    done (53s)
    id: fhmihpagi991********
    folder_id: b1geoelk7fld********
    created_at: "2025-05-20T17:39:01Z"
    name: fromcliencrypted
    type_id: network-hdd
    zone_id: ru-central1-a
    size: "21474836480"
    block_size: "4096"
    status: READY
    source_image_id: fd8lb5jnr2m2********
    disk_placement_policy: {}
    hardware_generation:
      legacy_features:
        pci_topology: PCI_TOPOLOGY_V1
    kms_key:
      key_id: abj73fd9mekk********
      version_id: abjdno4pqi67********
    

    Once created, the disk will get the Creating status. Wait until the disk status changes to Ready before using it.

  5. Delete the image:

    yc compute image delete <image_name>
    

    Result:

    done (15s)
    
  6. Delete the unencrypted disk:

    yc compute disk delete <unencrypted_disk_name>
    

    Result:

    done (7s)
    

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the relevant documentation on the Terraform website or its mirror.

If you do not have Terraform yet, install it and configure the Yandex Cloud provider.

To encrypt a disk using Terraform:

  1. In the Terraform configuration file, describe the resources you want to create:

    # Creating a Yandex Key Management Service key
    
    resource "yandex_kms_symmetric_key" "my-key" {
      name                = "Encrypt key"
      default_algorithm   = "AES_256"
      rotation_period     = "8760h"
      deletion_protection = true
      lifecycle {
        prevent_destroy = true
      }
    }
    
    # Creating an image
    
    resource "yandex_compute_image" "image-1" {
      name        = "disk-image"
      source_disk = "<unencrypted_disk_ID>"
    }
    
    # Creating an encrypted disk
    
    resource "yandex_compute_disk" "empty-disk" {
      name       = "<encrypted_disk_name>"
      type       = "network-hdd"
      zone       = "ru-central1-a"
      size       = 20
      block_size = 4096
      image_id   = yandex_compute_image.image-1.id
      kms_key_id = yandex_kms_symmetric_key.my-key.id
      depends_on = [yandex_compute_image.image-1]
    }
    

    Where:

    • source_disk: Unencrypted disk ID.
    • name: Name of the encrypted disk you are creating.

    For more information about yandex_compute_disk properties, see the relevant provider documentation.

  2. Create the resources:

    1. In the terminal, go to the directory where you edited the configuration file.

    2. Make sure the configuration file is correct using this command:

      terraform validate
      

      If the configuration is correct, you will get this message:

      Success! The configuration is valid.
      
    3. Run this command:

      terraform plan
      

      You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.

    4. Apply the changes:

      terraform apply
      
    5. Type yes and press Enter to confirm the changes.

    Once created, the disk will get the Creating status. Wait until the disk status changes to Ready before using it.

  3. Delete the image.

  4. Delete the unencrypted disk.

  1. Create a Yandex Key Management Service encryption key using the create REST API method for the SymmetricKey resource or the SymmetricKeyService/Create gRPC API call.

  2. Create an image using the create REST API method for the Image resource or the ImageService/Create gRPC API call. Specify the disk ID in your request.

    To request a list of available disks, use the list REST API method or the DiskService/List gRPC API call.

  3. Create an encrypted disk from an image using the create REST API method for the Disk resource or the DiskService/Create gRPC API call.

    Once created, the disk will get the Creating status. Wait until the disk status changes to Ready before using it.

  4. Delete an image using the delete REST API method for the Image resource or the ImageService/Delete gRPC API call.

  5. Delete an unencrypted disk using the delete REST API method for the Disk resource or the DiskService/Delete gRPC API call.

See alsoSee also

  • Encryption in Compute Cloud
  • Encrypting an image
  • Encrypting an image

Was the article helpful?

Previous
Moving a disk to a different availability zone
Next
Getting disk info
© 2025 Direct Cursus Technology L.L.C.