Enabling deletion protection for a Compute Cloud instance group
Deletion protection prevents accidental deletion of an instance group. You cannot delete a group while the value is true. To delete a group with protection on, you must turn it off first.
- In the management console
, open the folder containing the instance group in question. - Go to Compute Cloud.
- In the left-hand panel, select
Instance groups. - Select a group to enable deletion protection for.
- In the top-right corner of the page, click Edit.
- Enable Deletion protection.
- 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 an instance group:
yc compute instance-group update --help -
Get a list of instance groups in the default folder:
yc compute instance-group listResult:
+----------------------+----------------------+--------+------+ | ID | NAME | STATUS | SIZE | +----------------------+----------------------+--------+------+ | cl15b3mrkk88******** | first-instance-group | ACTIVE | 3 | +----------------------+----------------------+--------+------+ -
Select
IDof the instance group in question. -
In the YAML file that was used to create the group, specify
deletion_protection: true. If this YAML file was not saved, get the instance group info and create a new one, e.g.,specification.yaml. For more information, see Creating a fixed-size instance group. -
Update the instance group in the default folder:
yc compute instance-group update \ --id <instance_group_ID> \ --file specification.yamlInstance Groups will initiate an instance group update.
Result:
done (4m55s) id: cl15b3mrkk88******** folder_id: b1g07hj5r6i4******** created_at: "2025-12-10T10:51:35.963Z" name: vm-grup description: This instance group was created using a YAML configuration file. instance_template: platform_id: standard-v3 resources_spec: memory: "2147483648" cores: "2" boot_disk_spec: mode: READ_WRITE disk_spec: type_id: network-ssd size: "21474836480" image_id: fd8fhpd6j1ea******** network_interface_specs: - network_id: enp1djcrd94k******** primary_v4_address_spec: {} scheduling_policy: {} scale_policy: fixed_scale: size: "3" deploy_policy: max_unavailable: "1" strategy: PROACTIVE allocation_policy: zones: - zone_id: ru-central1-b load_balancer_state: {} managed_instances_state: target_size: "3" service_account_id: ajeb9l33h6mu******** status: ACTIVE deletion_protection: true application_load_balancer_state: {}
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Open the Terraform configuration file and add the
deletion_protectionproperty to the instance group description:... resource "yandex_compute_instance_group" "ig-1" { name = "fixed-ig" folder_id = "<folder_ID>" service_account_id = "<service_account_ID>" deletion_protection = true depends_on = [yandex_resourcemanager_folder_iam_member.compute_editor] instance_template { platform_id = "standard-v3" resources { memory = 2 cores = 2 } ... } }Where
deletion_protectionis instance group deletion protection:trueorfalse. You cannot delete a group while the value istrue. The default value isfalse.For more information about
yandex_compute_instance_groupproperties, see this Terraform article. -
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
-
Check the instance group update using the management console
or this CLI command:yc compute instance-group get <instance_group_name>
Use the update REST API method for the InstanceGroup resource or the InstanceGroupService/Update gRPC API call.
To request a list of available instance groups, use the listInstances REST API method or the InstanceGroupService/ListInstances gRPC API call.
Disable deletion protection
To disable instance group deletion protection:
- In the management console
, open the folder containing the instance group in question. - Go to Compute Cloud.
- In the left-hand panel, select
Instance groups. - Select the group to disable deletion protection for.
- In the top-right corner of the page, click Edit.
- Disable Deletion protection.
- 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 an instance group:
yc compute instance-group update --help -
Get a list of instance groups in the default folder:
yc compute instance-group listResult:
+----------------------+----------------------+--------+------+ | ID | NAME | STATUS | SIZE | +----------------------+----------------------+--------+------+ | cl15b3mrkk88******** | first-instance-group | ACTIVE | 3 | +----------------------+----------------------+--------+------+ -
Select
IDof the instance group in question. -
In the YAML file that was used to create the group, set
deletion_protection: false. If this YAML file was not saved, get the instance group info and create a new one, e.g.,specification.yaml. For more information, see Creating a fixed-size instance group. -
Disable deletion protection:
yc compute instance-group update \ --id <instance_group_ID> \ --file specification.yamlInstance Groups will initiate an instance group update.
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Open the Terraform configuration file and set
deletion_protectiontofalsein the instance group description:... resource "yandex_compute_instance_group" "ig-1" { name = "fixed-ig" folder_id = "<folder_ID>" service_account_id = "<service_account_ID>" deletion_protection = false depends_on = [yandex_resourcemanager_folder_iam_member.compute_editor] instance_template { platform_id = "standard-v3" resources { memory = 2 cores = 2 } ... } }For more information about
yandex_compute_instance_groupproperties, see this Terraform article. -
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
-
-
Check the instance group update using the management console
or this CLI command:yc compute instance-group get <instance_group_name>
Use the update REST API method for the InstanceGroup resource or the InstanceGroupService/Update gRPC API call.
To request a list of available instance groups, use the listInstances REST API method or the InstanceGroupService/ListInstances gRPC API call.