Configuring deletion protection
To prevent accidental deletion of a static public IP address, enable deletion protection for it.
You can disable this option when you no longer need it.
Enabling deletion protection
- In the management console
, navigate to the folder where you reserved the IP address. - In the list of services, select Virtual Private Cloud.
- In the left-hand panel, select
IP addresses. - In the row with the IP address, click
and select Enable deletion protection. - In the window that opens, click Enable.
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 address attributes:
yc vpc address update --help -
Get the list of addresses in the folder:
yc vpc address listResult:
+----------------------+------+---------------+----------+------+ | ID | NAME | ADDRESS | RESERVED | USED | +----------------------+------+---------------+----------+------+ | e2l46k8conff******** | | 84.201.177.41 | false | true | +----------------------+------+---------------+----------+------+ -
Enable deletion protection:
yc vpc address update --deletion-protection <address_name_or_ID>
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 IP address description:resource "yandex_vpc_address" "addr" { ... 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 IP address deletion protection, use the update REST API method for the Address resource or the AddressService/Update gRPC API call and provide the following in the request:
-
ID of the address you want to disable protection for in the
addressIdparameter.To get the address ID, use the list REST API method for the Address resource or the AddressService/List gRPC API call and provide the folder ID in the
folderIdrequest parameter.To learn how to find out the folder ID, see Getting the folder ID.
-
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.
Disabling deletion protection
- In the management console
, navigate to the folder where you reserved the IP address. - In the list of services, select Virtual Private Cloud.
- In the left-hand panel, select
IP addresses. - In the row with the IP address, click
and select Disable deletion protection. - In the window that opens, click Disable.
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 address attributes:
yc vpc address update --help -
Get the list of addresses in the folder:
yc vpc address listResult:
+----------------------+------+---------------+----------+------+ | ID | NAME | ADDRESS | RESERVED | USED | +----------------------+------+---------------+----------+------+ | e2l46k8conff******** | | 84.201.177.41 | false | true | +----------------------+------+---------------+----------+------+ -
Disable deletion protection:
yc vpc address update --deletion-protection=false <address_name_or_ID>
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 IP address description, set
deletion_protectiontofalse.resource "yandex_vpc_address" "addr" { ... 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 disable deletion protection for the IP address, use the update REST API method for the Address resource or the AddressService/Update gRPC API call and provide the following in the request:
-
ID of the address you want to disable protection for in the
addressIdparameter.To get the address ID, use the list REST API method for the Address resource or the AddressService/List gRPC API call and provide the folder ID in the
folderIdrequest parameter.To learn how to find out the folder ID, see Getting the folder ID.
-
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.