Configuring deletion protection
To prevent accidental deletion of a network load balancer, enable deletion protection for it.
You can disable protection when you no longer need it.
Enabling deletion protection
Warning
Even with balancer deletion protection enabled, one can still delete its listeners and target groups.
- In the management console
, select Network Load Balancer. - To the right of your load balancer name, click
and select Edit. - Enable the Deletion protection setting.
- Click Save.
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.
-
See the description of the CLI command for updating balancer attributes:
yc load-balancer network-load-balancer update --help -
Enable deletion protection:
yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \ --deletion-protectionYou can get the load balancer ID and name 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 relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Open the current configuration file describing the infrastructure.
-
Add the
deletion_protectionparameter to the load balancer description:resource "yandex_lb_network_load_balancer" "foo" { ... deletion_protection = true ... } -
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 validateTerraform will show any errors found in your configuration files.
-
-
Apply the changes.
-
Run this command to view the planned changes:
terraform planIf 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 enable deletion protection, use the update REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/Update gRPC API call and provide the following in the request:
- Name of the
deletionProtectionparameter in theupdateMaskparameter. truein thedeletionProtectionparameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.
Disable deletion protection
- In the management console
, select Network Load Balancer. - To the right of your load balancer name, click
and select Edit. - Disable the Deletion protection setting.
- Click Save.
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.
-
See the description of the CLI command for updating balancer attributes:
yc load-balancer network-load-balancer update --help -
Disable deletion protection:
yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \ --deletion-protection=falseYou can get the load balancer ID and name 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 relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Open the current configuration file describing the infrastructure.
-
In the load balancer description, change the
deletion_protectionvalue tofalse:resource "yandex_lb_network_load_balancer" "foo" { ... deletion_protection = false ... } -
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 validateTerraform will show any errors found in your configuration files.
-
-
Apply the changes.
-
Run this command to view the planned changes:
terraform planIf 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 enable deletion protection, use the update REST API method for the NetworkLoadBalancer resource or the NetworkLoadBalancerService/Update gRPC API call and provide the following in the request:
- Name of the
deletionProtectionparameter in theupdateMaskparameter. falsein thedeletionProtectionparameter.
Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.