Deleting a Network Load Balancer target group
Alert
Before deleting a target group, detach it from the network load balancer. You cannot restore a target group after it is deleted.
To delete a target group:
- In the management console
, select the folder where you need to delete a target group. - In the list of services, select Network Load Balancer.
- In the left-hand panel, select
Target groups. - Click
next to the target group you need to delete. - In the menu that opens, select Delete.
- In the window that opens, click Delete.
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 deleting a target group:
yc load-balancer target-group delete --help
-
Delete a target group from the default folder:
yc load-balancer target-group delete <target_group_name_or_ID>
You can get the target group ID and name with the list of target groups 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 delete a target group created with Terraform:
-
Open the Terraform configuration file and delete the section describing the target group.
resource "yandex_lb_target_group" "foo" { name = "<target_group_name>" target { subnet_id = "<subnet_ID>" address = "<target_internal_IP_address>" } target { subnet_id = "<subnet_ID>" address = "<resource_2_internal_IP_address>" } }
-
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 delete a target group, use the delete REST API method for the TargetGroup resource or the TargetGroupService/Delete gRPC API call.
You can get the target group ID with the list of target groups in the folder.