[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Managing an instance group > Enable deletion protection

# Enabling deletion protection for a Compute Cloud instance group

Deletion protection prevents accidental deletion of an [instance group](../../concepts/instance-groups/index.md). You cannot delete a group while the value is `true`. To delete a group with protection on, you must turn it off first.

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), open the folder containing the instance group in question.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/layers-3-diagonal.svg) **Instance groups**.
  1. Select a group to enable deletion protection for.
  1. In the top-right corner of the page, click **Edit**.
  1. Enable **Deletion protection**.
  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI command for updating an instance group:

     ```bash
     yc compute instance-group update --help
     ```

  1. Get a list of instance groups in the default folder:

     ```bash
     yc compute instance-group list
     ```
     
     Result:
     
     ```text
     +----------------------+----------------------+--------+------+
     |          ID          |          NAME        | STATUS | SIZE |
     +----------------------+----------------------+--------+------+
     | cl15b3mrkk88******** | first-instance-group | ACTIVE |    3 |
     +----------------------+----------------------+--------+------+
     ```

  1. Select `ID` of the instance group in question.
  1. In the YAML file that was used to create the group, set `deletion_protection: true`. If this YAML file was not saved, get the instance group [info](get-info.md) and create a new one, e.g., `specification.yaml`. For more information, see [Creating a fixed-size instance group](create-fixed-group.md).
  1. Update the instance group in the default folder:

      ```bash
      yc compute instance-group update \
        --id <instance_group_ID> \
        --file specification.yaml
      ```

     Instance Groups will initiate an instance group update.

     Result:

      ```yaml
      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: {}
      ```

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  1. Open the Terraform configuration file and add the `deletion_protection` property to the instance group description:

     ```hcl
     ...
     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_protection` is instance group deletion protection: `true` or `false`. You cannot delete a group while the value is `true`. The default value is `false`.

     For more information about `yandex_compute_instance_group` properties in Terraform, see [this provider guide](../../../terraform/resources/compute_instance_group.md).

  1. Apply the changes:

     1. In the terminal, navigate to the configuration file directory.
     1. Make sure the configuration is correct using this command:
     
        ```bash
        terraform validate
        ```
     
        If the configuration is valid, you will get this message:
     
        ```bash
        Success! The configuration is valid.
        ```
     
     1. Run this command:
     
        ```bash
        terraform plan
        ```
     
        You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
     1. Apply the configuration changes:
     
        ```bash
        terraform apply
        ```
     
     1. Type `yes` and press **Enter** to confirm the changes.

  1. Check the instance group update using the [management console](https://console.yandex.cloud) or this [CLI](../../../cli/index.md) command:

     ```bash
     yc compute instance-group get <instance_group_name>
     ```


- API {#api}

  Use the [update](../../instancegroup/api-ref/InstanceGroup/update.md) REST API method for the [InstanceGroup](../../instancegroup/api-ref/InstanceGroup/index.md) resource or the [InstanceGroupService/Update](../../instancegroup/api-ref/grpc/InstanceGroup/update.md) gRPC API call.

  To request a list of available instance groups, use the [listInstances](../../instancegroup/api-ref/InstanceGroup/listInstances.md) REST API method or the [InstanceGroupService/ListInstances](../../instancegroup/api-ref/grpc/InstanceGroup/listInstances.md) gRPC API call.

{% endlist %}

## Disable deletion protection {#disable}

To disable instance group deletion protection:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), open the folder containing the instance group in question.
  1. Navigate to **Compute Cloud**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/layers-3-diagonal.svg) **Instance groups**.
  1. Select the group to disable deletion protection for.
  1. In the top-right corner of the page, click **Edit**.
  1. Disable **Deletion protection**.
  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI command for updating an instance group:

     ```bash
     yc compute instance-group update --help
     ```

  1. Get a list of instance groups in the default folder:

     ```bash
     yc compute instance-group list
     ```
     
     Result:
     
     ```text
     +----------------------+----------------------+--------+------+
     |          ID          |          NAME        | STATUS | SIZE |
     +----------------------+----------------------+--------+------+
     | cl15b3mrkk88******** | first-instance-group | ACTIVE |    3 |
     +----------------------+----------------------+--------+------+
     ```

  1. Select `ID` of the instance group in question.
  1. 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](get-info.md) and create a new one, e.g., `specification.yaml`. For more information, see [Creating a fixed-size instance group](create-fixed-group.md).
  1. Disable deletion protection:

     ```bash
      yc compute instance-group update \
        --id <instance_group_ID> \
        --file specification.yaml
     ```

     Instance Groups will initiate an instance group update.

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  1. Open the Terraform configuration file and set `deletion_protection` to `false` in the instance group description:

     ```hcl
     ...
     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_group` properties in Terraform, see [this provider guide](../../../terraform/resources/compute_instance_group.md).

  1. Apply the changes:

     1. In the terminal, navigate to the configuration file directory.
     1. Make sure the configuration is correct using this command:
     
        ```bash
        terraform validate
        ```
     
        If the configuration is valid, you will get this message:
     
        ```bash
        Success! The configuration is valid.
        ```
     
     1. Run this command:
     
        ```bash
        terraform plan
        ```
     
        You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
     1. Apply the configuration changes:
     
        ```bash
        terraform apply
        ```
     
     1. Type `yes` and press **Enter** to confirm the changes.

  1. Check the instance group update using the [management console](https://console.yandex.cloud) or this [CLI](../../../cli/index.md) command:

     ```bash
     yc compute instance-group get <instance_group_name>
     ```

- API {#api}

  Use the [update](../../instancegroup/api-ref/InstanceGroup/update.md) REST API method for the [InstanceGroup](../../instancegroup/api-ref/InstanceGroup/index.md) resource or the [InstanceGroupService/Update](../../instancegroup/api-ref/grpc/InstanceGroup/update.md) gRPC API call.

  To request a list of available instance groups, use the [listInstances](../../instancegroup/api-ref/InstanceGroup/listInstances.md) REST API method or the [InstanceGroupService/ListInstances](../../instancegroup/api-ref/grpc/InstanceGroup/listInstances.md) gRPC API call.

{% endlist %}

#### Useful links {#see-also}

* [Deleting an instance group](delete.md)