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
    • AI Studio
    • 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
    • Education and Science
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Network Load Balancer
  • Getting started
    • All guides
      • Information about current network load balancers
      • Creating a load balancer
      • Creating an internal load balancer
      • Stopping and starting a load balancer
      • Changing load balancer settings
      • Moving a VM to a target group in a new availability zone
      • Deleting a load balancer
      • Checking target health statuses
      • Adding a listener
      • Deleting a listener
    • Viewing service resource operations
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Network load balancers
  3. Moving a VM to a target group in a new availability zone

Moving a VM to a target group in a new availability zone

Written by
Yandex Cloud
Updated at July 29, 2025

To move NLB backend VMs to a target group in a different availability zone:

  1. Move your VMs to the new availability zone.

  2. Replace targets in the target group:

    Management console
    CLI
    Terraform
    API
    1. In the management console, select the folder containing the network load balancer.
    2. In the list of services, select Network Load Balancer.
    3. In the left-hand panel, select Target groups.
    4. Select the target group in question.
    5. Under Targets, remove the old VMs and add new ones.

    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 removing targets from a target group:

      yc load-balancer target-group remove-targets --help
      
    2. Get a list of Network Load Balancer target groups in the default folder.

    3. Get a list of targets linked to the target group.

    4. Remove old VMs from the target group:

      yc load-balancer target-group remove-targets <target_group_ID> \
        --target subnet-id=<VM_1_subnet_ID>,address=<VM_1_internal_IP_address> \
        --target subnet-id=<VM_2_subnet_ID>,address=<VM_2_internal_IP_address> \
        ...
        --target subnet-id=<VM_n_subnet_ID>,address=<VM_n_internal_IP_address>
      

      Where:

      • <target_group_ID>: ID of the target group to remove targets from.
      • --target: Settings of the target within the target group:
        • subnet-id: Subnet ID of the target to remove.
        • address: Internal IP address of the target to remove.

      Result:

      done (4s)
      id: enplckhtn77s********
      folder_id: b1gt6g8ht345********
      created_at: "2023-10-16T10:42:18Z"
      name: sample-tg
      region_id: ru-central1
      targets:
      
    5. See the description of the CLI command for adding targets to a target group:

      yc load-balancer target-group add-targets --help
      
    6. Get a list of subnets in the default folder:

      yc vpc subnet list
      

      Result:

      +----------------------+------------+----------------------+----------------+---------------+------------------+
      |          ID          |    NAME    |      NETWORK ID      | ROUTE TABLE ID |     ZONE      |      RANGE       |
      +----------------------+------------+----------------------+----------------+---------------+------------------+
      | b0cnd1srghnm******** | rucentrald | enpv51f8lple******** |                | ru-central1-d | [192.168.3.0/24] |
      | e2li9tcgi7ii******** | rucentralb | enpv51f8lple******** |                | ru-central1-b | [192.168.0.0/24] |
      | e9b4a9ksc88k******** | rucentrala | enpv51f8lple******** |                | ru-central1-a | [192.168.1.0/24] |
      +----------------------+------------+----------------------+----------------+---------------+------------------+
      
    7. Get a list of VMs in the default folder:

      yc compute instance list
      

      Result:

      +----------------------+------------+-------------------+---------+-----------------+--------------+
      |          ID          |    NAME    |      ZONE ID      | STATUS  |   EXTERNAL IP   | INTERNAL IP  |
      +----------------------+------------+-------------------+---------+-----------------+--------------+
      | fhmkchjddi40******** | sample-vm1 | ru-central1-a | RUNNING | 130.193.**.***  | 192.168.1.9  |
      | fhm13ts43oml******** | sample-vm2 | ru-central1-a | RUNNING | 158.160.***.*** | 192.168.1.32 |
      | epdsj30mndgj******** | sample-vm3 | ru-central1-b | RUNNING | 51.250.***.***  | 192.168.0.7  |
      +----------------------+------------+-------------------+---------+-----------------+--------------+
      
    8. Add targets to the target group:

      yc load-balancer target-group add-targets <target_group_ID> \
        --target subnet-id=<VM_1_subnet_ID>,address=<VM_1_internal_IP_address> \
        --target subnet-id=<VM_2_subnet_ID>,address=<VM_2_internal_IP_address>
        ...
        --target subnet-id=<VM_n_subnet_ID>,address=<VM_n_internal_IP_address>
      

      Where:

      • <target_group_ID>: ID of the target group to add targets to.
      • --target: Settings of the target within the target group:
        • subnet-id: Subnet ID of the target to add.
        • address: Internal IP address of the target to add.

      Result:

      done (4s)
      id: enplckhtn77s********
      folder_id: b1gt6g8ht345********
      ...
          address: 192.168.1.32
        - subnet_id: e9b4a9ksc88k********
          address: 192.168.1.9
      

    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. Open the Terraform configuration file, find the section describing the target group, and edit the subnet_id and address values under target:

      Target group description example
      resource "yandex_lb_target_group" "foo" {
        name        = "<target_group_name>"
        target {
          subnet_id = "<subnet_ID>"
          address   = "<resource_1_internal_IP_address>"
        }
        target {
          subnet_id = "<subnet_ID>"
          address   = "<resource_2_internal_IP_address>"
        }
      }
      
    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.

    You can check updates in the management console or using this CLI command:

    yc load-balancer target-group get <target_group_name>
    
    1. To remove targets from a target group, use the removeTargets REST API method for the TargetGroup resource or the TargetGroupService/RemoveTargets gRPC API call.
    2. To add targets to a target group, use the addTargets REST API method for the TargetGroup resource or the TargetGroupService/AddTargets gRPC API call.
  3. If you are using an internal network load balancer and need to move it to a subnet in the new availability zone that will host your VMs:

    1. Delete the current listener of your load balancer.
    2. Add a new listener for the new availability zone.

    This will change the network load balancer IP address.

  4. Make sure the target group VMs in the new availability zone have passed health checks and got the HEALTHY status.

    If the new VMs remain UNHEALTHY for too long, make sure their security groups are configured to allow health check traffic.

Was the article helpful?

Previous
Changing load balancer settings
Next
Deleting a load balancer
© 2025 Direct Cursus Technology L.L.C.