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
      • Stopping and starting a VM
      • Resetting a Windows Server VM user password
      • Attaching a disk to a VM
      • Detaching a disk from a VM
      • Moving a VM to a different availability zone
      • Moving a VM to a different folder
      • Moving a VM to a different cloud
      • Adding another network interface to a VM
      • Deleting a network interface from a VM
      • Assigning a public IP address to a VM
      • Unassigning a public IP address from a VM
      • Making a VM public IP address static
      • Reassigning a public IP address from one VM to another
      • Updating the VM internal IP address
      • Updating a VM
      • Changing VM computing resources
      • Changing VM security groups
      • VM maintenance policy management
      • Configuring VM access permissions
      • Linking a service account to a VM
      • Deleting a VM
    • Viewing service resource operations
    • Viewing metrics in Monitoring
  • Yandex Container Solution
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Limitations
  • Moving a VM
  • Updating a VM folder
  • Updating a VM subnet
  1. Step-by-step guides
  2. Managing a VM
  3. Moving a VM to a different folder

Moving a VM to a different folder

Written by
Yandex Cloud
Updated at July 29, 2025
  • Limitations
  • Moving a VM
    • Updating a VM folder
    • Updating a VM subnet

When you create a VM, it is placed in the current folder.

In Yandex Cloud, you can move a VM to a different folder within a single cloud. You do not have to stop the VM to move it.

Learn more about the Yandex Cloud resource hierarchy here.

LimitationsLimitations

When moving a VM, keep in mind the following limitations:

  • Yandex Monitoring does not support metric relocation: existing metrics remain in the source folder, and new ones will be created in the destination folder.
  • You can only move VMs within a single cloud.

Moving a VMMoving a VM

Updating a VM folderUpdating a VM folder

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. Get a list of all VMs in the default folder:

    yc compute instance list
    

    Result:

    +----------------------+-----------------+---------------+---------+----------------------+
    |          ID          |       NAME      |    ZONE ID    | STATUS  |     DESCRIPTION      |
    +----------------------+-----------------+---------------+---------+----------------------+
    | fhm0b28lgfp4******** | first-instance  | ru-central1-a | RUNNING | my first vm via CLI  |
    | fhm9gk85nj7g******** | second-instance | ru-central1-a | RUNNING | my second vm via CLI |
    +----------------------+-----------------+---------------+---------+----------------------+
    
  2. Get a list of all folders in the default cloud:

    yc resource-manager folder list
    

    Result:

    +----------------------+--------------------+------------------+--------+
    |          ID          |        NAME        |      LABELS      | STATUS |
    +----------------------+--------------------+------------------+--------+
    | b1gd129pp9ha******** | my-folder          |                  | ACTIVE |
    | b1g66mft1vop******** | default            |                  | ACTIVE |
    +----------------------+--------------------+------------------+--------+
    
  3. See the description of the CLI command for moving a VM:

    yc compute instance move --help
    
  4. Move the VM to a different folder with the following parameters:

    • In id, enter the VM ID, e.g., fhm0b28lgfp4********.
    • In destination-folder-id, specify the destination folder ID, e.g., b1gd129pp9ha********.
    yc compute instance move \
      --id fhm0b28lgfp4******** \
      --destination-folder-id b1gd129pp9ha********
    

    For more information about the yc compute instance move 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. Configure access permissions for the target folder. The account from the source folder you are going to use to perform the operation must have at least the compute.editor role for the target folder.

  2. Get the target folder ID.

  3. In the configuration file, add the following parameters to the yandex_compute_instance resource:

    resource "yandex_compute_instance" "vm-1" {
        ...
        allow_stopping_for_update = true
        folder_id = <target_folder_ID>
        ...
    }
    

    Where:

    • allow_stopping_for_update: Parameter to allow the VM to stop for updates.
    • folder_id: ID of the folder to deploy the VM in (by default, specified from the environment variable).

    For more information about yandex_compute_instance properties, see this Terraform article.

  4. Apply the new configuration:

    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 update all the required resources. You can check the update using the management console.

Use the move REST API method for the Instance resource or the InstanceService/Move gRPC API call.

Example

Below is an example of a Bash script for Linux.

To use it, get authenticated with the API and install cURL.

You can move a VM without stopping it.

  1. Create a script file:

    sudo touch <file_name>
    
  2. Open the file to write the script to:

    sudo nano <file_name>
    
  3. Place the script in the file:

    #!/bin/bash
    
    # Creating variables
    
    export IAM_TOKEN=`yc iam create-token`
    
    instanceId='<VM_ID>'
    bootDiskId='<VM_boot_disk_ID>'
    destinationFolderId='<folder_ID>'
    
    # Moving a VM
    
    curl \
      --request POST \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '{ "destinationFolderId": "'"${destinationFolderId}"'" }' \
      "https://compute.api.cloud.yandex.net/compute/v1/instances/{${instanceId}}:move"
    
    # Moving a boot disk
    
    curl \
      --request POST \
      --header "Authorization: Bearer ${IAM_TOKEN}" \
      --data '{ "destinationFolderId": "'"${destinationFolderId}"'" }' \
      "https://compute.api.cloud.yandex.net/compute/v1/disks/{${bootDiskId}}:move"
    

    Where:

    • IAM_TOKEN: IAM token for API authentication.
    • instanceId: ID of the VM to move.
    • bootDiskId: ID of the boot disk of the VM to move.
    • destinationFolderId: ID of the folder to move the VM to.
  4. Make the file executable:

    chmod +x <file_name>
    
  5. Run the script:

    ./<file_name>
    

Updating a VM subnetUpdating a VM subnet

After moving a VM, its network interfaces remain connected to the subnets in the source folder. To connect your VM to subnets in the destination folder, follow these steps:

Management console
CLI
Terraform
API
  1. In the management console, select the folder you moved the VM to.
  2. Select Compute Cloud.
  3. Click the VM name.
  4. Click Stop.
  5. In the window that opens, click Stop.
  6. Under Network, click in the top-right corner of the relevant network interface section and select Edit.
  7. In the Subnet field, select a new subnet and click Save.
    If a VM has multiple network interfaces, update the subnet for each one.
  8. Click Start.

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 updating a subnet:

    yc compute instance update-network-interface --help
    
  2. Stop the VM:

    yc compute instance stop fhm0b28lgfp4********
    
  3. Get a list of VM network interfaces by specifying the VM ID:

    yc compute instance get fhm0b28lgfp4********
    

    Result:

    ...
    network_interfaces:
      - index: "0"
        mac_address: d0:0d:24:**:**:**
        subnet_id: e2lpp96bvvgp********
        primary_v4_address:
          address: 192.168.2.23
      - index: "1"
        mac_address: d0:1d:24:**:**:**
        subnet_id: e2lrucutusnd********
        primary_v4_address:
          address: 192.168.1.32
      - index: "2"
        mac_address: d0:2d:24:**:**:**
        subnet_id: e2lv9c6aek1d********
        primary_v4_address:
          address: 192.168.4.26
    ...
    

    Save the index field value, i.e., the number of the network interface you want to connect to a different subnet.

  4. Run this command:

    yc compute instance update-network-interface fhm0b28lgfp4******** \
      --subnet-id e2lfibapq818******** \
      --ipv4-address auto \
      --network-interface-index 0 \
      --security-group-id enpi8m85mj14********
    

    Where:

    • --subnet-id: Subnet in the destination folder.
    • --ipv4-address: Internal IP address of the VM network interface in the subnet in the destination folder. Set to auto to enable automatic internal address assignment.
    • --network-interface-index: VM's network interface number you previously saved.
    • --security-group-id: Security group that will be assigned to the VM's network interface.

    Result:

    done (9s)
    id: fhm0b28lgfp4********
    folder_id: b1gd73mbrli7********
    created_at: "2023-11-16T06:09:46Z"
    name: oslogigor1
    zone_id: ru-central1-a
    platform_id: standard-v3
    resources:
      memory: "2147483648"
      cores: "2"
      core_fraction: "100"
    status: STOPPED
    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: epdophaf2gh9********
      auto_delete: true
      disk_id: epdophaf2gh9********
    network_interfaces:
      - index: "0"
        mac_address: d0:0d:24:**:**:**
        subnet_id: e2lfibapq818********
        primary_v4_address:
          address: 10.129.0.22
        security_group_ids:
          - enpi8m85mj14********
      - index: "1"
        mac_address: d0:1d:24:**:**:**
        subnet_id: e2lrucutusnd********
        primary_v4_address:
          address: 192.168.1.32
      - index: "2"
        mac_address: d0:2d:24:**:**:**
        subnet_id: e2lv9c6aek1d********
        primary_v4_address:
          address: 192.168.4.26
    gpu_settings: {}
    fqdn: relocated-vm.ru-central1.internal
    scheduling_policy: {}
    network_settings:
    type: STANDARD
    placement_policy: {}
    

    If a VM has multiple network interfaces, update the subnet for each one.

  5. Run the VM:

    yc compute instance start fhm0b28lgfp4********
    

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. Configure access permissions for the folder you are updating the VM subnet in. The account used to perform the operation must have at least the vpc.admin role for the this folder.

  2. If an additional subnet already exists, obtain its ID.

  3. Edit the yandex_compute_instance resource in the configuration file:

    resource "yandex_compute_instance" "vm-1" {
      ...
      network_interface {
        subnet_id = "<subnet_ID>"
      }
    
      allow_stopping_for_update = true
      ...
    }
    

    Where:

    • subnet_id: Subnet ID.
    • allow_stopping_for_update: Parameter to allow the VM to stop for updates.

    For more information about yandex_compute_instance properties, see this Terraform article.

  4. Apply the new configuration:

    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 update all the required resources. You can check the update using the management console.

Use the updateNetworkInterface REST API method for the Instance resource or the InstanceService/UpdateNetworkInterface gRPC API call.

Was the article helpful?

Previous
Moving a VM to a different availability zone
Next
Moving a VM to a different cloud
© 2025 Direct Cursus Technology L.L.C.