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 Network Load Balancer
  • Getting started
    • All guides
      • Information about existing target groups
      • Creating a target group
      • Attaching a target group to a load balancer
      • Detaching a target group from a load balancer
      • Deleting a target group
    • Viewing operations with resources
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Target groups
  3. Detaching a target group from a load balancer

Detaching a target group from a network load balancer

Written by
Yandex Cloud
Updated at May 13, 2025
Management console
CLI
Terraform
API

To detach a target group from a network load balancer:

  1. In the management console, select the folder where you want to detach a target group from a load balancer.
  2. In the list of services, select Network Load Balancer.
  3. Select the load balancer to detach a target group from.
  4. Under Target groups, click next to the target group in question.
  5. In the menu that opens, click Detach.
  6. In the window that opens, click Detach.

If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI command for detaching a target group from a network load balancer:

    yc load-balancer network-load-balancer detach-target-group --help
    
  2. Detach a target group from a network load balancer:

    yc load-balancer network-load-balancer detach-target-group <load_balancer_name_or_ID> \
       --target-group-id=<target_group_ID>
    

    You can get the load balancer ID and name, as well as the IDs of the attached target groups with the list of network load balancers in the folder.

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 documentation on the Terraform website or mirror website.

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

To detach a target group from a network load balancer created with Terraform:

  1. Open the Terraform configuration file and delete the section describing the target group.

    resource "yandex_lb_network_load_balancer" "foo" {
      name = "<network_load_balancer_name>"
      ...
      attached_target_group {
        target_group_id = "<target_group_ID>"
        healthcheck {
          name = "<health_check_name>"
          http_options {
            port = <port_number>
            path = "<URL>"
          }
        }
      }
      ...
    }
    
  2. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  3. Delete the network load balancer.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

To detach a target group from a network load balancer, use the detachTargetGroup REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/DetachTargetGroup gRPC API call, providing the following in your request:

  • Load balancer ID in the networkLoadBalancerId parameter.
  • Target group ID in the targetGroupId parameter.

You can get the IDs of the load balancer and attached target groups with the list of network load balancers in the folder.

Was the article helpful?

Previous
Attaching a target group to a load balancer
Next
Deleting a target group
Yandex project
© 2025 Yandex.Cloud LLC