Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Compute Cloud
  • Yandex Container Solution
    • Resource relationships
    • Graphics processing units (GPUs)
    • Images
      • Overview
      • Access
      • YAML specification
      • Instance template
      • Variables in an instance template
      • Scaling types
      • Instance health checks and automatic recovery
        • Overview
        • Allocating instances across zones
        • Deployment algorithm
        • Rules for updating instances
        • Updating secondary disks in an instance template
      • Integrating with network and L7 load balancers
      • Handling a stateful workload
      • Stopping and pausing an instance group
      • Sequentially restarting and recreating instances in a group
      • Statuses
    • Dedicated host
    • Encryption
    • Backups
    • Quotas and limits
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Algorithm for updating secondary disks
  • Mapping by name
  • Mapping by parameters
  • Use cases
  1. Concepts
  2. Instance groups
  3. Updating
  4. Updating secondary disks in an instance template

Updating secondary disks in an instance template

Written by
Yandex Cloud
Updated at April 18, 2025
  • Algorithm for updating secondary disks
    • Mapping by name
    • Mapping by parameters
  • Use cases

Note

Changing disk parameters leads to instance recreation.

The following parameters can be updated without recreating a disk:

  • description: Editing disk description.
  • size: Increasing disk size.
  • preserve_after_instance_delete: Setting or removing a flag.

If you update any other parameter of the disk_spec object or decrease the disk size, the disk is recreated.

Algorithm for updating secondary disksAlgorithm for updating secondary disks

The decision to reconfigure or recreate a disk is based on one of the mapping algorithms:

  • By disk names: Mapping the name parameter values (main method).
  • By disk parameters: Mapping other parameter values (deprecated method).

Mapping by nameMapping by name

This algorithm maps disk names between the current and new YAML specifications. The system deletes the disks with names missing in the new specification. The system creates the disks with names missing in the current specification. You can uniquely identify a disk you want to update, add, or delete.

To use name-based mapping for disks, give a unique name to each disk in the YAML specification.

Note

In the same specification, names should be assigned either to all secondary disks or none of them.

When you change from the deprecated algorithm to the name-based mapping algorithm, the very first time the disks will be mapped by parameters. On subsequent runs, they will be mapped by names.

Example of secondary disk mapping by namesExample of secondary disk mapping by names

The current specification describes two secondary disks, a 20 GB one and a 50 GB one:

instance_template:
...
  secondary_disk_specs:
    - name: disk-2
      mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 21474836480
    - name: disk-3
      mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 53687091200
...

An updated specification contains two secondary disks, a 60 GB one and a 10 GB one:

instance_template:
...
  secondary_disk_specs:
    - name: disk-2
      mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 64424509440
    - name: disk-4
      mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 10737418240
...

When updating, the following actions will be performed:

  1. The disk named disk-2 from the current specification will be mapped to disk-2 from the updated specification because their names match. Its size will be increased to 60 GB without recreation, the data on the disk will be preserved.
  2. disk-3 will be deleted from the current specification because there is no such disk in the updated specification.
  3. disk-4 from the updated specification will be created and added because there is no such disk in the current specification.

Mapping by parametersMapping by parameters

Note

The parameter-based mapping algorithm for secondary disks does uniquely identify disks within an instance and is deprecated. Use name-based disk mapping.

If disk names are not used in the specification, the mapping and updating follow this algorithm:

  1. For each disk in the current specification, the group searches through the new specification for:

    • A disk with the same parameters.
    • A disk with parameters that can be obtained without recreation.

    The two specifications are searched sequentially, starting from the first disk.

  2. If the disk is found, the disks are considered successfully mapped. If needed, the disk parameters are changed according to the new specification. From then on, these disks take no part in further mapping.

  3. If a disk from the current specification cannot be matched with a disk in the new specification, the disk is deleted.

  4. If the new specification has a disk left unmapped to any disk from the old specification, such a disk gets created.

Example of secondary disk mapping by parametersExample of secondary disk mapping by parameters

The current specification describes two secondary disks, a 20 GB one and a 50 GB one:

instance_template:
...
  secondary_disk_specs:
    - mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 21474836480
    - mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 53687091200
...

An updated specification contains two secondary disks, a 60 GB one and a 10 GB one:

instance_template:
...
  secondary_disk_specs:
    - mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 64424509440
    - mode: READ_WRITE
      disk_spec:
        preserve_after_instance_delete: false
        type_id: network-hdd
        size: 10737418240
...

All disk parameters, except for disk size, are the same in both specifications.

When updating, the following actions will be performed:

  1. The first disk in the current specification (20 GB) will be mapped to the first disk in the updated specification (60 GB). Its size will be increased to 60 GB without recreation, the data on the disk will be preserved.
  2. The second disk of the current specification (50 GB) will not be mapped to any disk of the new specification and will be deleted.
  3. A secondary disk of the new specification (10 GB) will be created and added.

Use casesUse cases

  • Updating an instance group under load

Was the article helpful?

Previous
Rules for updating instances
Next
Integrating with network and L7 load balancers
Yandex project
© 2025 Yandex.Cloud LLC