Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • 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
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Compute Cloud
    • All guides
      • Creating a Linux VM
      • Creating a VM from disks
      • Creating a VM with disks from snapshots
      • Creating a VM from a custom image
      • Creating a VM with a custom configuration script
      • Creating a VM with metadata from environment variables
      • Creating a VM instance with access to a Yandex Lockbox secret
      • Creating a VM with a GPU
      • Creating a VM with Gen 2 hardware
      • Making a VM preemptible
    • Viewing service resource operations
    • Viewing metrics in Monitoring
    • NVIDIA driver update guide
  • Yandex Container Solution
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Create an image with the Gen 2 hardware generation assigned
  • Upload your disk image to Yandex Cloud
  • Creating a disk image with the Gen 2 hardware generation assigned from another image, snapshot, or disk
  • Create a disk snapshot with the Gen 2 hardware generation assigned
  • Prepare the disk for a snapshot
  • Create a snapshot
  • Create a disk with the Gen 2 hardware generation assigned
  • Create a VM running on Gen 2 hardware
  1. Step-by-step guides
  2. Creating a VM
  3. Creating a VM with Gen 2 hardware

Creating a VM with Gen 2 hardware

Written by
Yandex Cloud
Improved by
Danila N.
Updated at January 13, 2026
  • Create an image with the Gen 2 hardware generation assigned
    • Upload your disk image to Yandex Cloud
    • Creating a disk image with the Gen 2 hardware generation assigned from another image, snapshot, or disk
  • Create a disk snapshot with the Gen 2 hardware generation assigned
    • Prepare the disk for a snapshot
    • Create a snapshot
  • Create a disk with the Gen 2 hardware generation assigned
  • Create a VM running on Gen 2 hardware

The VM runs on virtualized hardware of the generation assigned to the medium (i.e., image, snapshot, or disk) the VM was created based on.

Therefore, to create a VM running on Gen 2 hardware, you must first create a medium with Gen 2 assigned, and then create your VM from this medium.

To create a VM running on virtualized Gen 2 hardware, proceed as follows:

  1. Prepare a medium of one of these types: image, snapshot, or disk.
  2. Create a VM from the medium you prepared.

Create an image with the Gen 2 hardware generation assignedCreate an image with the Gen 2 hardware generation assigned

You can create a VM image with the Gen 2 hardware generation assigned either from your own image pre-uploaded to Yandex Cloud or from existing images, snapshots, and disks available in Yandex Cloud.

Upload your disk image to Yandex CloudUpload your disk image to Yandex Cloud

You can upload your own UEFI and GPT-enabled VM image to Compute Cloud to create VMs running on Gen 2 hardware. You can create an image in Compute Cloud from a prepared image file uploaded to Yandex Object Storage.

Prepare an image filePrepare an image file

Make sure the following requirements for boot disk images are met:

  • The virtio-net, virtio-blk, and virtio-pci drivers are installed. If you are going to attach file storages to your VM, you also need to install the virtiofs driver. For details, see this guide.
  • The ttyS0 terminal (COM1) is configured as the serial console. For details, see this guide.
  • The network interface runs correctly when starting the VM and gets the IP address via DHCP.
  • The cloud-init package is installed and configured to work with our metadata service. Run sudo yum install cloud-init to install the package for CentOS or sudo apt update && sudo apt install -y cloud-init to install it for Debian or Ubuntu.
  • For an image based on an AMI, cloud platform verification for the VM instance is disabled in the cloud-init settings. For details, see this guide.
  • The system firewall is configured to only allow the minimum ports required for your applications to run securely and the SSH port (by default, 22 TCP).
  • The SSH server starts automatically at VM startup.
  • The services running your application are resilient to VM reboots.
  • The boot disk uses MBR partitioning.
  • The disk is mounted by its UUID rather than by name.
  • The file system is not encrypted.

Supported formats: Qcow2, VMDK, RAW, and VHD.

For configuration steps, see Setting up a custom disk image.

Upload the image file to Object StorageUpload the image file to Object Storage

Upload your image file to Object Storage and get a shareable link:

  1. If you have no Object Storage bucket yet, create one with restricted access.
  2. Upload your image to the bucket via the management console, AWS CLI, or WinSCP. In Object Storage terminology, your uploaded image will be called an object.
  3. Get a signed link to download the image from the bucket. Use this link when creating an image in Compute Cloud.

In Compute Cloud, create an image with the Gen 2 hardware generation assignedIn Compute Cloud, create an image with the Gen 2 hardware generation assigned

To create a new image using the link you got in Object Storage:

Management console
CLI
Terraform
API
  1. In the management console, select the folder where you want to create the image.

  2. Go to Compute Cloud.

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

  4. Click Upload image, and in the window that opens:

    1. In the Name field, enter a name for the image. Follow these naming requirements:

      • 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.
    2. Optionally, in the Description and Labels fields, add a description and labels for the new image.

    3. In the Link to image in Object Storage field, paste the image file link you got in Object Storage earlier.

    4. In the Hardware generation field, select the Gen 2 (GPT, UEFI) hardware generation.

    5. To enable image optimization for deployment, expand Additional and enable the Optimization option.

    6. Click Upload.

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. See the description of the Yandex Cloud CLI command for creating an image:

    yc compute image create --help
    
  2. To create a new image with the Gen 2 hardware generation assigned using a link, run this command:

    yc compute image create \
      --name <image_name> \
      --source-uri "<image_URL>" \
      --hardware-generation-id generation2 \
      --pooled
    

    Where:

    • --name: Name to assign to the image. Follow these naming requirements:

      • 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.
    • --source-uri: Image link you got in Object Storage.

    • --pooled: Enables image optimization for deployment. This is an optional setting. By default, the optimization is disabled.

    Result:

    done (12s)
    id: fd86a13e6ro9********
    folder_id: b1gt6g8ht345********
    created_at: "2025-12-05T16:26:46Z"
    name: my-own-gen2-image
    storage_size: "1891631104"
    min_disk_size: "1891631104"
    status: READY
    os:
      type: LINUX
    hardware_generation:
      generation2_features: {}
    

For more information about the yc compute image create command, see the CLI reference.

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 create an image:

  1. Specify the parameters of the yandex_compute_image resource in the configuration file.

    Here is an example of the configuration file structure:

    resource "yandex_compute_image" "image-1" {
      name                 = "<image_name>"
      source_url           = "<image_link>"
      pooled               = "true|false"
    
      hardware_generation {
        generation2_features {}
      }
    }
    

    Where:

    • name: Name to assign to the image. Follow these naming requirements:

      • 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.
    • source_url: Image link in Object Storage.

    • pooled: Enables image optimization for deployment. The possible values are:

      • true: Optimization enabled.
      • false: Optimization disabled.

      This is an optional setting. By default, the optimization is disabled.

    For detailed information about the yandex_compute_image resource parameters, see this Terraform provider guide.

  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.

    Terraform will create all the required resources. You can check new resources in the management console or using this CLI command:

    yc compute image list
    

Use the create REST API method for the Image resource or the ImageService/Create gRPC API call.

For example, to create an image with the Gen 2 hardware generation assigned using REST API:

  1. Install cURL.

  2. Get an IAM token used for API authentication:

    • Guide for a Yandex account user
    • Guide for a service account
    • Guide for a federated account
    • Guide for a local account
  3. For your request to run smoothly, save the IAM token you got to the IAM_TOKEN environment variable:

    export IAM_TOKEN="<IAM_token_contents>"
    
  4. Create a file containing the body of your image create request (e.g., body.json) and add the following code to it:

    body.json

    {
      "folderId": "<folder_ID>",
      "name": "<image_name>",
      "uri": "<link_to_uploaded_image>",
      "pooled": "true|false",
      "hardwareGeneration": {
        "generation2Features": {}
      }
    }
    

    Where:

    • folderId: ID of the image folder.

    • name: Image name. Follow these naming requirements:

      • 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.
    • uri: Image link in Object Storage.

    • pooled: Enables image optimization for deployment. The possible values are:

      • true: Optimization enabled.
      • false: Optimization disabled.

      This is an optional setting. By default, the optimization is disabled.

  5. Run this http request:

    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '@body.json' \
      https://compute.api.cloud.yandex.net/compute/v1/images
    

    Result:

    {
    "done": false,
    "metadata": {
      "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateImageMetadata",
      "imageId": "fd8g5p4hllq8********"
    },
    "id": "fd8m1tfm92kr********",
    "description": "Create image",
    "createdAt": "2025-12-05T16:41:54.452564354Z",
    "createdBy": "ajeol2afu1js********",
    "modifiedAt": "2025-12-05T16:41:54.452564354Z"
    }
    

After you create the image, you can delete the original file from the bucket.

Creating a disk image with the Gen 2 hardware generation assigned from another image, snapshot, or diskCreating a disk image with the Gen 2 hardware generation assigned from another image, snapshot, or disk

By default, a newly created image is assigned the hardware generation assigned to the original image, snapshot, or disk the image was created from. However, you can explicitly specify a hardware generation different from that assigned to the original image, snapshot, or disk.

Public images available for installation on VMs in Yandex Cloud Marketplace get Gen 1.1 or Gen 1.2 assigned by default. At the same time, some public images (e.g., those running Linux Ubuntu 24.04 LTS) support Gen 2 hardware with UEFI boot and the GPT partition table; you can use such images to create a disk or an image of your own with Gen 2 assigned. Other public images do not support UEFI boot, so you cannot use them to create a VM running on Gen 2 hardware.

Note

You can create a new image with the Gen 2 hardware generation assigned from a public image in Yandex Cloud Marketplace only with the help the Yandex Cloud CLI, Terraform, or API.

To create an image from an existing image, snapshot, or disk:

Management console
CLI
Terraform
API
  1. In the management console, select the folder where you want to create an image.

  2. Go to Compute Cloud.

  3. Depending on the source you want to create the new image from, select Disks and storages, Snapshots, or Images in the left-hand panel.

  4. Depending on the source type you selected, in the list that opens, click next to the image, snapshot, or disk, and select Create image. In the window that opens:

    1. In the Name field, enter a name for the new image. Follow these naming requirements:

      • 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.
    2. Optionally, in the Description and Labels fields, add a description and labels for the new image.

    3. Expand the Additional section and select Gen 2 (GPT, UEFI) in the Hardware generation field.

      Alert

      Make sure the source operating system boot loader supports UEFI boot mode and the GPT partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.

    4. To enable image optimization for deployment, enable the Optimization option.

    5. Click Create.

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.

Alert

Make sure the source operating system boot loader supports UEFI boot mode and the GPT partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.

  1. See the description of the Yandex Cloud CLI command for creating an image:

    yc compute image create --help
    
  2. To create a new image with the Gen 2 hardware generation assigned from an existing image, snapshot, or disk, run this command:

    yc compute image create \
      --name <image_name> \
      --source-image-id <source_image_ID> \
      --source-snapshot-id <source_snapshot_ID> \
      --source-disk-id <source_disk_ID> \
      --hardware-generation-id generation2 \
      --pooled
    

    Where:

    • --name: Name to assign to the image. Follow these naming requirements:

      • 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.
    • Selecting a source for your image:

      • --source-image-id: Source image ID. Instead of the ID, you can provide its name in --source-image-name.
      • --source-snapshot-id: Source snapshot ID. Instead of the ID, you can provide its name in --source-snapshot-name.
      • --source-disk-id: Source disk ID. Instead of the ID, you can provide its name in --source-disk-name.

      Note

      --source-image-id, --source-image-name, --source-snapshot-id, --source-snapshot-name, --source-disk-id, and --source-disk-name are mutually exclusive: you can use only one of them in the command.

    • --pooled: Enables image optimization for deployment. This is an optional setting. By default, the optimization is disabled.

    Result:

    done (9s)
    id: fd86kup8c7pa********
    folder_id: b1gt6g8ht345********
    created_at: "2025-12-05T06:57:09Z"
    name: my-sample-gen2-image
    storage_size: "9877585920"
    min_disk_size: "21474836480"
    product_ids:
      - f2ercusam4no********
    status: READY
    os:
      type: LINUX
    hardware_generation:
      generation2_features: {}
    

For more information about the yc compute image create command, see the CLI reference.

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.

  1. Define the parameters of the yandex_compute_image resource in the configuration file.

    Here is an example of the configuration file structure:

    resource "yandex_compute_image" "image-1" {
      name                 = "<image_name>"
      source_image         = "<source_image_ID>"
      source_snapshot      = "<source_snapshot_ID>"
      source_disk          = "<source_disk_ID>"
      pooled               = "true|false"
    
      hardware_generation {
        generation2_features {}
      }
    }
    

    Alert

    Make sure the source operating system boot loader supports UEFI boot mode and the GPT partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.

    Where:

    • name: Name to assign to the image. Follow these naming requirements:

      • 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.
    • Selecting a source for your image:

      • source_image: Source image ID.
      • source_snapshot: Source snapshot ID.
      • source_disk: Source disk ID.

      Note

      source_image, source_snapshot, and source_disk are mutually exclusive: you can use only one of them in the configuration file.

    • pooled: Enables image optimization for deployment. The possible values are:

      • true: Optimization enabled.
      • false: Optimization disabled.

      This is an optional setting. By default, the optimization is disabled.

      For detailed information about the yandex_compute_image resource parameters, see this Terraform provider guide.

  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.

    Terraform will create all the required resources. You can check new resources in the management console or using this CLI command:

    yc compute image list
    

Use the create REST API method for the Image resource or the ImageService/Create gRPC API call.

For example, to create an image with the Gen 2 hardware generation assigned using REST API:

  1. Install cURL.

  2. Get an IAM token used for API authentication:

    • Guide for a Yandex account user
    • Guide for a service account
    • Guide for a federated account
    • Guide for a local account
  3. For your request to run smoothly, save the IAM token you got to the IAM_TOKEN environment variable:

    export IAM_TOKEN="<IAM_token_contents>"
    
  4. Create a file containing the body of your image create request (e.g., body.json) and add the following code to it:

    body.json

    {
      "folderId": "<folder_ID>",
      "name": "<image_name>",
      "imageId": "<source_image_ID>",
      "snapshotId": "<source_snapshot_ID>",
      "diskId": "<source_disk_ID>",
      "pooled": "true|false",
      "hardwareGeneration": {
        "generation2Features": {}
      }
    }
    

    Where:

    • folderId: ID of the image folder.

    • name: Image name. Follow these naming requirements:

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

    Alert

    Make sure the source operating system boot loader supports UEFI boot mode and the GPT partition table. Otherwise, virtual machines created from the new image will not be able to boot the operating system.

    • Selecting a source for your image:

      • imageId: Source image ID.
      • snapshotId: Source snapshot ID.
      • diskId: Source disk ID.

      Note

      The imageId, snapshotId, and diskId fields are mutually exclusive: you can use only one of them in the request.

    • pooled: Enables image optimization for deployment. The possible values are:

      • true: Optimization enabled.
      • false: Optimization disabled.

      This is an optional setting. By default, the optimization is disabled.

  5. Run this http request:

    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '@body.json' \
      https://compute.api.cloud.yandex.net/compute/v1/images
    

    Result:

    {
    "done": false,
    "metadata": {
      "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateImageMetadata",
      "imageId": "fd8j3jind4ij********"
    },
    "id": "fd8a7eged70b********",
    "description": "Create image",
    "createdAt": "2025-12-05T08:51:44.937021154Z",
    "createdBy": "ajeol2afu1js********",
    "modifiedAt": "2025-12-05T08:51:44.937021154Z"
    }
    

This will create an image with the Gen 2 virtualized hardware generation assigned.

Create a disk snapshot with the Gen 2 hardware generation assignedCreate a disk snapshot with the Gen 2 hardware generation assigned

You can snapshot the boot disk of an existing VM running on Gen 1.1 or Gen 1.2 generation virtualized hardware and assign the Gen 2 generation hardware to this snapshot.

Prepare the disk for a snapshotPrepare the disk for a snapshot

A disk snapshot only contains the data that was written to the disk at the time its snapshot was created. If the disk is attached to a running VM, the OS and app cache will not be included in the snapshot.

To ensure the snapshot data integrity:

Linux
Other operating systems
  1. Stop all disk write operations in applications.

  2. Write the OS cache to the disk:

    sync
    
  3. Freeze the file system:

    sudo fsfreeze --freeze <mount_point>
    

    Where --freeze is the parameter to freeze the file system. Replace <mount_point> with the folder where the file system is mounted, e.g., /mnt/vdc2.

  4. Create a snapshot by following the steps below.

  5. Unfreeze the file system:

    sudo fsfreeze --unfreeze <mount_point>
    

    Where --unfreeze is the parameter to unfreeze the file system. Replace <mount_point> with the folder where the file system is mounted, e.g., /mnt/vdc2.

  1. Stop the VM (see Stopping).
  2. Wait until the VM status changes to STOPPED.

Create a snapshotCreate a snapshot

To create a disk snapshot with the Gen 2 hardware generation assigned:

Note

You can assign to a snapshot a generation different from the one assigned to the source disk only using the Yandex Cloud CLI, Terraform, or API.

CLI
Terraform
API

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. See the description of the CLI command for creating snapshots:

    yc compute snapshot create --help
    
  2. Create a snapshot in the default folder:

    yc compute snapshot create \
      --name <snapshot_name> \
      --disk-id <source_disk_ID> \
      --hardware-generation-id generation2
    

    Where:

    • --name: Snapshot name. Follow these naming requirements:

      • 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.
    • --disk-id: ID of the disk you are creating the snapshot for. Instead of the ID, you can provide its name in --disk-name.

    Result:

    done (18s)
    id: fd8jnmpan5ff********
    folder_id: b1gt6g8ht345********
    created_at: "2025-12-05T14:10:15Z"
    name: my-gen2-snapshot
    storage_size: "3632267264"
    disk_size: "21474836480"
    product_ids:
      - f2ebiogvi127********
    status: READY
    source_disk_id: epd89t47vnhd********
    hardware_generation:
      generation2_features: {}
    

For more information about the yc compute snapshot create command, see the CLI reference.

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.

  1. Define the parameters of the yandex_compute_snapshot resource in the configuration file.

    Here is an example of the configuration file structure:

    resource "yandex_compute_snapshot" "snapshot-1" {
      name                 = "<snapshot_name>"
      source_disk_id       = "<disk_ID>"
      hardware_generation {
        generation2_features {}
      }
    }
    

    Where:

    • name: Name to assign to the snapshot. Follow these naming requirements:

      • 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.
    • source_disk_id: ID of the disk to create the snapshot for.

    For detailed information about the yandex_compute_snapshot resource parameters, see this Terraform provider guide.

  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.

    Terraform will create all the required resources. You can check new resources in the management console or using this CLI command:

    yc compute snapshot list
    

Use the create REST API method for the Snapshot resource or the SnapshotService/Create gRPC API call.

For example, to create a snapshot with the Gen 2 hardware generation assigned using REST API:

  1. Install cURL.

  2. Get an IAM token used for API authentication:

    • Guide for a Yandex account user
    • Guide for a service account
    • Guide for a federated account
    • Guide for a local account
  3. For your request to run smoothly, save the IAM token you got to the IAM_TOKEN environment variable:

    export IAM_TOKEN="<IAM_token_contents>"
    
  4. Create a file containing the body of your snapshot create request (e.g., body.json), and add the following code to it:

    body.json

    {
      "folderId": "<folder_ID>",
      "name": "<snapshot_name>",
      "diskId": "<disk_ID>",
      "hardwareGeneration": {
        "generation2Features": {}
      }
    }
    

    Where:

    • folderId: ID of the snapshot folder.

    • name: Snapshot name. Follow these naming requirements:

      • 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.
    • diskId: ID of the disk you are making a snapshot of.

  5. Run this http request:

    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '@body.json' \
      https://compute.api.cloud.yandex.net/compute/v1/snapshots
    

    Result:

    {
    "done": false,
    "metadata": {
      "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateSnapshotMetadata",
      "snapshotId": "fd8apannhdo9********",
      "diskId": "epd89t47vnhd********"
    },
    "id": "epd473ndlm58********",
    "description": "Create snapshot",
    "createdAt": "2025-12-05T14:43:02.803028670Z",
    "createdBy": "ajeol2afu1js********",
    "modifiedAt": "2025-12-05T14:43:02.803028670Z"
    }
    

This will create a disk snapshot with the Gen 2 virtualized hardware generation assigned.

Create a disk with the Gen 2 hardware generation assignedCreate a disk with the Gen 2 hardware generation assigned

By default, a newly created disk is assigned the hardware generation assigned to the original image or snapshot the disk was created from. However, you can explicitly specify a hardware generation different from that assigned to the original image or snapshot.

To create a disk with the Gen 2 hardware generation assigned:

Management console
CLI
Terraform
API
  1. In the management console, select the folder where you want to create an image.

  2. Go to Compute Cloud.

  3. In the left-hand panel, select Disks and storages and click Create disk. In the window that opens:

    1. Name the disk in the Name field. Follow these naming requirements:

      • 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.
    2. In the Availability zone field, select an availability zone for the new disk.

    3. Depending on the source you are creating the disk from, in the Contents field, select Snapshot or Image and select the snapshot or image from the list that opens.

    4. In the Type field, select disk type. Possible values:

      • SSD: Fast network drive; SSD network block storage.
      • HDD: Standard network drive; HDD network block storage.
      • SSD IO: Enhanced performance network drive with redundancy.
      • Non-replicated SSD: Enhanced performance network drive without redundancy.
    5. In the Size field, specify the required disk size.

    6. Expand the Additional section and select Gen 2 (GPT, UEFI) in the Hardware generation field.

    7. Click Create 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. View the description of the Yandex Cloud CLI command to create a disk:

    yc compute disk create --help
    
  2. Create a disk with the Gen 2 hardware generation assigned in the default folder:

    yc compute disk create \
      --name <disk_name> \
      --zone <availability_zone> \
      --type <disk_type> \
      --size <disk_size> \
      --source-image-id <source_image_ID> \
      --source-snapshot-id <source_snapshot_ID> \
      --hardware-generation-id generation2
    

    Where:

    • --name: Disk name. Follow these naming requirements:

      • 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.
    • --zone: Availability zone of the new disk.

    • --type: Disk type. Possible values:

      • network-ssd: Fast network drive; SSD network block storage.
      • network-hdd: Standard network drive; HDD network block storage.
      • network-ssd-nonreplicated: Enhanced performance network drive without redundancy.
      • network-ssd-io-m3: Enhanced performance network drive with redundancy.
    • --size: Disk size in GB. For example, specify --size 32 to create a 32 GB disk.

    • Selecting a source for your disk:

      • --source-image-id: ID of the image you are creating the disk based on. Instead of the ID, you can provide its name in --source-image-name.
      • --source-snapshot-id: ID of the snapshot you are creating the disk based on. Instead of the ID, you can provide its name in --source-snapshot-name.

      Note

      --source-image-id, --source-image-name, --source-snapshot-id, and --source-snapshot-name are mutually exclusive: you can use only one of them in the command.

    Result:

    done (9s)
    id: fv45fajiusvq********
    folder_id: b1gt6g8ht345********
    created_at: "2025-12-04T08:15:45Z"
    name: ubuntu2404-gen2-disk
    type_id: network-hdd
    zone_id: ru-central1-a
    size: "34359738368"
    block_size: "4096"
    product_ids:
      - f2ebiogvi127********
    status: READY
    source_image_id: fd8bnguet48k********
    disk_placement_policy: {}
    hardware_generation:
      generation2_features: {}
    

For more information about the yc compute disk create command, see the CLI reference.

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.

  1. Define the parameters of the yandex_compute_disk resource in the configuration file.

    Here is a configuration file example:

    resource "yandex_compute_disk" "my-disk" {
      name            = "<disk_name>"
      type            = "<disk_type>"
      zone            = "<availability_zone>"
      size            = <disk_size>
      image_id        = "<source_image_ID>"
      snapshot_id     = "<source_snapshot_ID>"
    
      hardware_generation {
        generation2_features {}
      }
    }
    

    Where:

    • name: Name to assign to the disk. Follow these naming requirements:

      • 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.
    • type: Disk type. Possible values:

      • network-ssd: Fast network drive; SSD network block storage.
      • network-hdd: Standard network drive; HDD network block storage.
      • network-ssd-nonreplicated: Enhanced performance network drive without redundancy.
      • network-ssd-io-m3: Enhanced performance network drive with redundancy.
    • zone: Availability zone of the new disk.

    • size: Disk size in GB.

    • Selecting a source for your disk:

      • image_id: ID of the image you are creating the disk based on.
      • snapshot_id: ID of the snapshot you are creating the disk based on.

      Note

      image_id and snapshot_id are mutually exclusive: you can use only one of them in the configuration file.

      For detailed information about the yandex_compute_disk resource parameters, see this Terraform provider guide.

  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.

    Terraform will create all the required resources. You can check new resources in the management console or using this CLI command:

    yc compute disk list
    

Use the create REST API method for the Disk resource or the DiskService/Create gRPC API call.

For example, to create a disk with the Gen 2 hardware generation assigned using REST API:

  1. Install cURL.

  2. Get an IAM token used for API authentication:

    • Guide for a Yandex account user
    • Guide for a service account
    • Guide for a federated account
    • Guide for a local account
  3. For your request to run smoothly, save the IAM token you got to the IAM_TOKEN environment variable:

    export IAM_TOKEN="<IAM_token_contents>"
    
  4. Create a file containing the body of your disk create request (e.g., body.json), and add the following code to it:

    body.json

    {
      "folderId": "<folder_ID>",
      "name": "<disk_name>",
      "typeId": "<disk_type>",
      "zoneId": "<availability_zone>",
      "size": "<disk_size_in_bytes>",
      "imageId": "<source_image_ID>",
      "snapshotId": "<source_snapshot_ID>",
      "hardwareGeneration": {
        "generation2Features": {}
      }
    }
    

    Where:

    • folderId: ID of the disk folder.

    • name: Disk name. Follow these naming requirements:

      • 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.
    • typeId: Disk type. Possible values:

      • network-ssd: Fast network drive; SSD network block storage.
      • network-hdd: Standard network drive; HDD network block storage.
      • network-ssd-nonreplicated: Enhanced performance network drive without redundancy.
      • network-ssd-io-m3: Enhanced performance network drive with redundancy.
    • zoneId: Availability zone of the new disk.

    • size: Disk size, in bytes.

    • Selecting a source for your disk:

      • imageId: ID of the image you are creating the disk based on.
      • snapshotId: ID of the snapshot you are creating the disk based on.

      Note

      The imageId and snapshotId fields are mutually exclusive, you can use only one of them in the request.

  5. Run this http request:

    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '@body.json' \
      https://compute.api.cloud.yandex.net/compute/v1/disks
    

    Result:

    {
    "done": false,
    "metadata": {
      "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateDiskMetadata",
      "diskId": "fv4lmsdol4fi********"
    },
    "id": "fv4pt28gishg********",
    "description": "Create disk",
    "createdAt": "2025-12-04T09:19:00.743099068Z",
    "createdBy": "ajeol2afu1js********",
    "modifiedAt": "2025-12-04T09:19:00.743099068Z"
    }
    

This will create a disk with the Gen 2 virtualized hardware generation assigned.

Create a VM running on Gen 2 hardwareCreate a VM running on Gen 2 hardware

Note

Before you create a VM, prepare a key pair (public and private) for SSH access to the VM.

Use a pre-prepared image, snapshot, or disk with the Gen 2 hardware generation assigned to create a VM based on that hardware generation:

Management console
CLI
Terraform
API
  1. In the management console, select the folder where you want to create your VM.

  2. Go to Compute Cloud.

  3. In the left-hand panel, select Virtual machines and click Create virtual machine.

  4. Under Location, select the availability zone where your VM will reside.

    Note

    If creating your VM by attaching a ready-made boot disk to it, make sure your disk is in the same availability zone you are creating your VM in.

  5. Under Boot disk image, navigate to the Custom tab and click Select. In the window that opens:

    • To create a VM from a pre-prepared snapshot:

      1. Make sure you selected Create at the top of the screen and Snapshot in the Contents field.

      2. Select the snapshot from the list. Optionally, use the filter.

      3. Name the VM boot disk in the Name field. Follow these naming requirements:

        • 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.
      4. In the Type and Size fields, select the type and size for your new disk.

      5. Optionally, in the Additional field, enable Delete along with the virtual machine to activate auto-deletion of the new boot disk together with the VM.

      6. Click Add disk.

    • To create a VM from a pre-prepared image:

      1. Make sure you selected Create at the top of the screen.

      2. In the Contents field, select Image.

      3. Select the image from the list. Optionally, use the filter.

      4. Name the VM boot disk in the Name field. Follow these naming requirements:

        • 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.
      5. In the Type and Size fields, select the type and size for your new disk.

      6. Optionally, in the Additional field, enable Delete along with the virtual machine to activate auto-deletion of the new boot disk together with the VM.

      7. Click Add disk.

    • To create a VM from a pre-prepared disk:

      1. At the top of the screen, select Attach existing.
      2. Select the disk from the list. Optionally, use the filter.
      3. Optionally, in the Additional field, enable Delete along with the virtual machine to activate auto-deletion of the new boot disk together with the VM.
      4. Click Add disk.
  6. Under Computing resources, select one of the preset configurations or create a custom one. To create a custom configuration:

    • Go to the Custom tab.
    • Select a platform.
    • Specify the guaranteed performance and required number of vCPUs, as well as RAM size.
    • Optionally, enable a software-accelerated network.
    • Make your VM preemptible, if required.
  7. Under Network settings:

    • In the Subnet field, enter the ID of a subnet in the new VM’s availability zone. Alternatively, select a cloud network from the list.

      • Each network must have at least one subnet. If your network has no subnets, create one by selecting Create subnet.

      • If you do not have a network, click Create network to create one:

        • In the window that opens, specify the network name and select the folder to host the network.
        • Optionally, enable the Create subnets setting to automatically create subnets in all availability zones.
        • Click Create network.
    • In the Public IP address field, select an IP address assignment method:

      • Auto: To assign a random IP address from the Yandex Cloud IP address pool. In this case, you can enable DDoS protection using the option below.
      • List: To select a public IP address from the list of previously reserved static addresses. For more information, see Converting a dynamic public IP address to static.
      • No address: Not to assign a public IP address.
    • Select the relevant security groups. If you leave this field empty, the default security group will be assigned to the VM.

    • Expand Additional and select a method for assigning internal addresses in the Internal IPv4 address field:

      • Auto: To assign a random IP address from the pool of IP addresses available in the selected subnet.
      • Manual: To manually assign a private IP address to the VM.
      • Enable DDoS protection, if required. The option is available if you previously selected the automatic IP assignment method in the public address settings.
    • Optionally, create records for your VM in the DNS zone:

      • Expand DNS settings for internal addresses and click Add record.
      • Specify a zone, FQDN, and TTL for the record. When setting the FQDN, you can enable Detect automatically for the zone.
        You can add multiple records to internal DNS zones. For more information, see Cloud DNS integration with Compute Cloud.
      • To create another record, click Add record.

    If you want to add another network interface to your VM, click Add network interface and repeat the settings from this step for the new interface. You can add up to eight network interfaces to a single VM.

  8. Under Access, select SSH key and specify the VM access credentials:

    • In the Login field, enter the username.

      Alert

      Do not use root or other reserved usernames. For operations requiring root privileges, use the sudo command.

    • In the SSH key field, select the SSH key saved in your organization user profile.

      If there are no SSH keys in your profile or you want to add a new key:

      1. Click Add key.

      2. Enter a name for the SSH key.

      3. Select one of the following:

        • Enter manually: Paste the contents of the public SSH key. You need to create an SSH key pair on your own.

        • Load from file: Upload the public part of the SSH key. You need to create an SSH key pair on your own.

        • Generate key: Automatically create an SSH key pair.

          When adding a new SSH key, an archive containing the key pair will be created and downloaded. In Linux or macOS-based operating systems, unpack the archive to the /home/<user_name>/.ssh directory. In Windows, unpack the archive to the C:\Users\<user_name>/.ssh directory. You do not need additionally enter the public key in the management console.

      4. Click Add.

      The system will add the SSH key to your organization user profile. If the organization has disabled the ability for users to add SSH keys to their profiles, the added public SSH key will only be saved in the user profile inside the newly created resource.

  9. Under General information, enter a name for your VM:

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

    Note

    The VM name is used to generate an internal FQDN, which is set only once, when you create the VM. If the internal FQDN is important to you, make sure to choose an appropriate name for your VM.

  10. Click Create VM.

  1. View the description of the CLI command to create a VM:

    yc compute instance create --help
    
  2. Create a VM in the default folder:

    yc compute instance create \
      --name <VM_name> \
      --zone <VM_availability_zone> \
      --network-interface subnet-id=<subnet_ID>,nat-ip-version=ipv4 \
      --create-boot-disk name=<disk_name>,type=<disk_type>,size=<disk_size>,image-id=<image_ID>,snapshot-id=<snapshot_ID>,auto-delete=true \
      --use-boot-disk disk-id=<ID_of_existing_disk>,auto-delete=true \
      --ssh-key "<path_to_public_SSH_key>"
    

    Where:

    • --name: VM name. Follow these naming requirements:

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

      Note

      The VM name is used to generate an internal FQDN, which is set only once, when you create the VM. If the internal FQDN is important to you, make sure to choose an appropriate name for your VM.

    • --zone: Availability zone of the new VM.

      The VM availability zone must be the same as that of the subnet.

      When creating a VM using a pre-prepared boot disk, the VM availability zone must be the same as that of the boot disk.

    • --network-interface: VM network interface settings:

      • subnet-id: Subnet ID.
      • nat-ip-version=ipv4: Public IP address. To create a VM without a public IP address, omit this parameter.

      If you want to add multiple network interfaces to your VM, specify the --network-interface parameter as many times as you need. You can add up to eight network interfaces to a single VM.

    • VM boot disk settings:

      Note

      --create-boot-disk and --use-boot-disk are mutually exclusive: you can use only one of them.

      • --create-boot-disk: Enables creating a new boot disk for the VM based on an image or snapshot:

        • name: Disk name. Follow these naming requirements:

          • 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.
        • type: Disk type. Possible values:

          • network-ssd: Fast network drive; SSD network block storage.
          • network-hdd: Standard network drive; HDD network block storage.
          • network-ssd-nonreplicated: Enhanced performance network drive without redundancy.
          • network-ssd-io-m3: Enhanced performance network drive with redundancy.
        • size: Disk size in GB.

        • Selecting a source for the boot disk:

          • image-id: ID of the pre-prepared image the VM boot disk will be created from.

          • snapshot-id: ID of the pre-prepared snapshot the VM boot disk will be created from.

            Note

            The image-id and snapshot-id keys are mutually exclusive, you can use only one of them.

        • auto-delete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.

      • --use-boot-disk: Allows using an existing pre-prepared boot disk for the VM:

        • disk-id: Existing boot disk ID.
        • auto-delete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.
    • --ssh-key: Path to the file with the public SSH key. The VM will automatically create a user named yc-user for this key.

    Result:

    done (19s)
    id: fv4l7qqpi4e0********
    folder_id: b1gt6g8ht345********
    created_at: "2025-12-05T18:23:55Z"
    name: my-first-gen2-vm
    zone_id: ru-central1-a
    platform_id: standard-v2
    resources:
      memory: "2147483648"
      cores: "2"
      core_fraction: "100"
    status: RUNNING
    metadata_options:
      gce_http_endpoint: ENABLED
      aws_v1_http_endpoint: ENABLED
      gce_http_token: ENABLED
      aws_v1_http_token: DISABLED
    boot_disk:
      mode: READ_WRITE
      device_name: fv4h89mv71cb********
      auto_delete: true
      disk_id: fv4h89mv71cb********
    network_interfaces:
      - index: "0"
        mac_address: d0:0d:15:3e:b5:99
        subnet_id: fl8dmq91iruu********
        primary_v4_address:
          address: 192.168.3.3
          one_to_one_nat:
            address: 158.160.***.***
            ip_version: IPV4
    serial_port_settings:
      ssh_authorization: OS_LOGIN
    gpu_settings: {}
    fqdn: fv4l7qqpi4e0********.auto.internal
    scheduling_policy: {}
    network_settings:
      type: STANDARD
    placement_policy: {}
    hardware_generation:
      generation2_features: {}
    application: {}
    
  1. In the configuration file, describe the resources you want to create:

    resource "yandex_compute_disk" "boot-disk" {
      name            = "<disk_name>"
      type            = "<disk_type>"
      zone            = "<availability_zone>"
      size            = "<disk_size>"
      image_id        = "<source_image_ID>"
      snapshot_id     = "<source_snapshot_ID>"
    }
    
    resource "yandex_compute_instance" "vm-1" {
      name                      = "<VM_name>"
      platform_id               = "standard-v3"
      zone                      = "<availability_zone>"
    
      resources {
        cores  = "<number_of_vCPUs>"
        memory = "<RAM_in_GB>"
      }
    
      boot_disk {
        auto_delete = true|false
        disk_id = yandex_compute_disk.boot-disk.id
      }
    
      network_interface {
        subnet_id = "<subnet_ID>"
        nat       = true
      }
    
      metadata = {
        ssh-keys = "<username>:<SSH_key_contents>"
      }
    }
    

    Where:

    • yandex_compute_disk: Boot disk description:

      Note

      Use the yandex_compute_disk resource if creating a new boot disk for the VM from a pre-prepared image or snapshot.

      If your new VM will use an existing pre-prepared boot disk, specify the disk's ID in the boot_disk.disk_id parameter of the yandex_compute_instance resource without creating a new yandex_compute_disk resource.

      • name: Disk name. Follow these naming requirements:

        • 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.
      • type: Disk type. Possible values:

        • network-ssd: Fast network drive; SSD network block storage.
        • network-hdd: Standard network drive; HDD network block storage.
        • network-ssd-nonreplicated: Enhanced performance network drive without redundancy.
        • network-ssd-io-m3: Enhanced performance network drive with redundancy.
      • zone: Availability zone the disk will reside in.

      • size: Disk size in GB.

      • Selecting a source for the boot disk:

        Note

        image_id and snapshot_id are mutually exclusive: you can use only one of them.

        • image_id: ID of the pre-prepared image the VM boot disk will be created from.
        • snapshot_id: ID of the pre-prepared snapshot the VM boot disk will be created from.

      For detailed information about the yandex_compute_disk resource parameters, see this Terraform provider guide.

    • yandex_compute_instance: VM description:

      • name: VM name. Follow these naming requirements:

        • 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.
      • platform_id: Platform.

      • zone: Availability zone the VM will reside in.

        The VM must reside in the same availability zone as the subnet, plus in the same availability zone as the boot disk if created from a pre-prepared disk.

      • resources: Number of vCPUs and amount of RAM available to the VM. The values must match the selected platform.

      • boot_disk: Boot disk settings.

        • disk_id: Disk ID. If your new VM will use an existing pre-prepared boot disk, specify its ID in this parameter.
        • auto_delete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.
      • network_interface: VM network interface settings:

        • subnet_id: ID of the subnet in the same availability zone as the new VM.
        • To automatically assign a public IP address to the VM, set nat = true.

        If you want to add multiple network interfaces to your VM, specify the network_interface section as many times as you need.

      • metadata: In the metadata, provide the user name and public SSH key for VM access. For more information, see VM metadata.

    For detailed information about the yandex_compute_instance resource parameters, see this Terraform provider guide.

  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.

    Terraform will create all the required resources. You can check new resources in the management console or using this CLI command:

    yc compute instance list
    

Use the create REST API method for the Instance resource or the InstanceService/Create gRPC API call.

For example, to create a VM using REST API:

  1. Install cURL.

  2. Get an IAM token used for API authentication:

    • Guide for a Yandex account user
    • Guide for a service account
    • Guide for a federated account
    • Guide for a local account
  3. For your request to run smoothly, save the IAM token you got to the IAM_TOKEN environment variable:

    export IAM_TOKEN="<IAM_token_contents>"
    
  4. Create a file containing the body of your VM create request (e.g., body.json), and add the following code to it:

    body.json

    {
      "folderId": "<folder_ID>",
      "name": "<VM_name>",
      "zoneId": "<availability_zone>",
      "platformId": "standard-v3",
      "resourcesSpec": {
        "memory": "<RAM_in_bytes>",
        "cores": "<number_of_vCPUs>"
      },
      "metadata": {
        "user-data": "#cloud-config\nusers:\n  - name: user\n    groups: sudo\n    shell: /bin/bash\n    sudo: 'ALL=(ALL) NOPASSWD:ALL'\n    ssh_authorized_keys:\n      - ssh-ed25519 AAAAB3N... user@example.com"
      },
      "bootDiskSpec": {
        "autoDelete": true,
        "diskSpec": {
          "size": "<disk_size_in_bytes>",
          "imageId": "<source_image_ID>",
          "snapshotId": "<source_snapshot_ID>"
        },
        "diskId": "<disk_ID>"
      },
      "networkInterfaceSpecs": [
        {
          "subnetId": "<subnet_ID>",
          "primaryV4AddressSpec": {
            "oneToOneNatSpec": {
              "ipVersion": "IPV4"
            }
          }
        }
      ]
    }
    

    Where:

    • folderId: ID of the VM folder.

    • name: VM name. Follow these naming requirements:

      • 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.
    • zoneId: Availability zone the VM will reside in.

      The VM must reside in the same availability zone as the subnet, plus in the same availability zone as the boot disk if created from a pre-prepared disk.

    • platformId: VM platform.

    • resourceSpec: Number of vCPUs and amount of RAM available to the VM. The values must match the selected platform.

    • metadata: In metadata, provide the public key for accessing the VM via SSH. For more information, see VM metadata.

    • bootDiskSpec: VM boot disk settings:

      • autoDelete: Auto-delete the boot disk together with the VM. See Disk auto-deletion.

      Note

      diskSpec and diskId are mutually exclusive: you can use only one of them.

      • diskSpec: Setting of the new boot disk if created from a pre-prepared image or snapshot:

        • size: New disk size, in bytes.

        • Selecting a source for the boot disk:

          Note

          imageId and snapshotId are mutually exclusive: you can use only one of them.

          • imageId: ID of the pre-prepared image the VM boot disk will be created from.
          • snapshotId: ID of the pre-prepared snapshot the VM boot disk will be created from.
      • diskId: ID of the existing pre-prepared boot disk if one is used to create the VM.

    • networkInterfaceSpecs: VM network interface settings:

      • subnetId: ID of the selected subnet. The subnet must be in the same availability zone as your new VM.

      • primaryV4AddressSpec: IP address to assign to the VM. To add a public IP address to your VM, specify the following:

        "primaryV4AddressSpec": {
          "oneToOneNatSpec": {
            "ipVersion": "IPV4"
          }
        }
        

      To add multiple network interfaces to your VM, provide an array with the required number of objects containing network interface settings in the networkInterfaceSpecs parameter.

  5. Run this http request:

    curl \
      --request POST \
      --header "Content-Type: application/json" \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '@body.json' \
      https://compute.api.cloud.yandex.net/compute/v1/instances
    

    Result:

    {
    "done": false,
    "metadata": {
      "@type": "type.googleapis.com/yandex.cloud.compute.v1.CreateInstanceMetadata",
      "instanceId": "fv41kcr9qbd8********"
    },
    "id": "fv4tll89q78c********",
    "description": "Create instance",
    "createdAt": "2025-12-05T20:37:44.940310692Z",
    "createdBy": "ajeol2afu1jsk********",
    "modifiedAt": "2025-12-05T20:37:44.940310692Z"
    }
    

See alsoSee also

  • Hardware generations

Was the article helpful?

Previous
Creating a VM with a GPU
Next
Making a VM preemptible
© 2026 Direct Cursus Technology L.L.C.