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 to delete a target group from. - In the list of services, select Network Load Balancer.
- In the left-hand panel, select
Target groups. - Click
in the line of the target group to delete. - In the menu that opens, select Delete.
- In the window that opens, click Delete.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
See the description of the CLI delete target group command:
yc load-balancer target-group delete --help
-
Delete the 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 a list of target groups in the folder.
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
To delete a target group created with Terraform:
-
Open the Terraform configuration file and delete the fragment with the target group description.
resource "yandex_lb_target_group" "foo" { name = "<target_group_name>" target { subnet_id = "<subnet_ID>" address = "<resource_internal_IP_address>" } target { subnet_id = "<subnet_ID>" address = "<resource_2_internal_IP_address>" } }
-
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Delete the network load balancer.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of 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 a list of target groups in the folder.