Detaching a target group from a network load balancer
To detach a target group from a network load balancer:
- In the management console
, select the folder where you want to detach a target group from a load balancer. - In the list of services, select Network Load Balancer.
- Select the load balancer to detach a target group from.
- Under Target groups, click
next to the target group in question. - In the menu that opens, click Detach.
- 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.
-
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
-
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
Terraform is distributed under the Business Source License
For more information about the provider resources, see the documentation on the Terraform
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:
-
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>" } } } ... }
-
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validate
Terraform will show any errors found in your configuration files.
-
-
Delete the network load balancer.
-
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.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply
-
Confirm updating the resources.
-
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.