[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud CDN](../../index.md) > [Step-by-step guides](../index.md) > Resources > Managing resource labels

# Managing resource labels

[CDN resource labels](../../concepts/labels.md) are key-value pairs used for logical CDN resource labeling.

## Adding or updating labels {#add-edit-label}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder the resource is in.
  1. Navigate to **Cloud CDN**.
  1. In the CDN resource row, click ![image](../../../_assets/console-icons/ellipsis.svg) and select ![image](../../../_assets/console-icons/pencil.svg) **Edit**.
  1. Under **Content**, find the **Labels** field.
  1. Click **Add label**.
  1. Enter a label in `key: value` format. To update an existing label, enter its key and a new value.
  1. Press **Enter**.
  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. View the description of the CLI command to update the CDN resource settings:

      ```bash
      yc cdn resource update --help
      ```

  1. Get a list of CDN resources in the default folder:

      ```bash
      yc cdn resource list
      ```

      Result:

      ```text
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      |          ID          |  CNAME  |           CREATED AT           |           UPDATED AT           | ACTIVE |                         OPTIONS                         |
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      | bc8jhcx5o47p******** | ****.ru | seconds:1734615244             | seconds:1734615244             | false  | edge_cache_settings:{enabled:true                       |
      |                      |         | nanos:439618000                | nanos:439638000                |        |  default_value:345600}                                  |
      |                      |         |                                |                                |        | query_params_options:{ignore_query_string:{enabled:true |
      |                      |         |                                |                                |        |  value:true}}  stale:{enabled:true  value:"error"       |
      |                      |         |                                |                                |        | value:"updating"}                                       |
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      ```

  1. Add labels by specifying the name of the CDN resource:

      ```bash
      yc cdn resource update <CDN_resource_ID> \
        --add-labels <label_1_key>=<label_1_value>,<label_2_key>=<label_2_value>,...,<label_n_key>=<label_n_value>
      ```

      Where `--add-labels` is a parameter to list CDN resource labels in `key=value` format.

      Result:

      ```text
      id: bc8jhcx5o47p********
      folder_id: b1g681qpemb4********
      cname: ****.ru
      ...
      labels:
        key2: value2
        key3: value3
        key4: value4
      ```

{% endlist %}

## Viewing labels {#get-label}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder the resource is in.
  1. Navigate to **Cloud CDN**.
  1. Navigate to the CDN resource.
  1. Under **Content**, find the **Labels** field.

- 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. View the description of the CLI command to update the CDN resource settings:

      ```bash
      yc cdn resource update --help
      ```

  1. Get a list of CDN resources in the default folder:

      ```bash
      yc cdn resource list
      ```

      Result:

      ```text
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      |          ID          |  CNAME  |           CREATED AT           |           UPDATED AT           | ACTIVE |                         OPTIONS                         |
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      | bc8jhcx5o47p******** | ****.ru | seconds:1734615244             | seconds:1734615244             | false  | edge_cache_settings:{enabled:true                       |
      |                      |         | nanos:439618000                | nanos:439638000                |        |  default_value:345600}                                  |
      |                      |         |                                |                                |        | query_params_options:{ignore_query_string:{enabled:true |
      |                      |         |                                |                                |        |  value:true}}  stale:{enabled:true  value:"error"       |
      |                      |         |                                |                                |        | value:"updating"}                                       |
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      ```

  1. Get information about the labels by specifying the name of the CDN resource:

      ```bash
      yc cdn resource get <CDN_resource_ID>
      ```

      Result:

      ```text
      id: bc8jhcx5o47p********
      folder_id: b1g681qpemb4********
      cname: ****.ru
      ...
      labels:
        key2: value2
        key3: value3
        key4: value4
      ```

{% endlist %}

## Deleting labels {#delete-label}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder the resource is in.
  1. Navigate to **Cloud CDN**.
  1. In the CDN resource row, click ![image](../../../_assets/console-icons/ellipsis.svg) and select ![image](../../../_assets/console-icons/pencil.svg) **Edit**.
  1. Under **Content**, find the **Labels** field.
  1. Click ![image](../../../_assets/console-icons/xmark.svg) next to the label.
  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. View the description of the CLI command to update the CDN resource settings:

      ```bash
      yc cdn resource update --help
      ```

  1. Get a list of CDN resources in the default folder:

      ```bash
      yc cdn resource list
      ```

      Result:

      ```text
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      |          ID          |  CNAME  |           CREATED AT           |           UPDATED AT           | ACTIVE |                         OPTIONS                         |
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      | bc8jhcx5o47p******** | ****.ru | seconds:1734615244             | seconds:1734615244             | false  | edge_cache_settings:{enabled:true                       |
      |                      |         | nanos:439618000                | nanos:439638000                |        |  default_value:345600}                                  |
      |                      |         |                                |                                |        | query_params_options:{ignore_query_string:{enabled:true |
      |                      |         |                                |                                |        |  value:true}}  stale:{enabled:true  value:"error"       |
      |                      |         |                                |                                |        | value:"updating"}                                       |
      +----------------------+---------+--------------------------------+--------------------------------+--------+---------------------------------------------------------+
      ```

  1. Delete labels by specifying the name of the CDN resource:

      ```bash
      yc cdn resource update <CDN_resource_ID> \
        --remove-labels <label_1_key>,<label_2_key>,...,<label_n_key>
      ```

      Where `--remove-labels` is a parameter to list the keys of the CDN resource labels.

      Result:

      ```text
      id: bc8jhcx5o47p********
      folder_id: b1g681qpemb4********
      cname: ****.ru
      ...
      labels:
        key2: value2
        key3: value3
        key4: value4
      ```

      To delete all labels, use the `--remove-all-labels` flag:

      ```bash
      yc cdn resource update <CDN_resource_ID> \
        --remove-all-labels
      ```

{% endlist %}