# Updating a Yandex Data Processing cluster

After creating a cluster, you can edit its basic and advanced settings.

You can disable sending cluster logs to Yandex Cloud Logging. For more information, see [Working with logs](logging.md#disable-logs).

You can also migrate a Yandex Data Processing cluster to a different availability zone. This process depends on the cluster type:

* [Migrating a lightweight cluster to a different availability zone](migration-to-an-availability-zone.md).
* [Migrating an HDFS cluster to a different availability zone](../tutorials/hdfs-cluster-migration.md).

{% list tabs group=instructions %}

- Management console {#console}

    To change Yandex Data Processing cluster settings:

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex Data Processing**.
    1. Select your cluster and click **Edit** in the top panel.
    1. Change the cluster name and description in the **Cluster name** and **Description** fields.
    1. Add or delete cluster [labels](../../resource-manager/concepts/labels.md) in the **Labels** field:
    1. Update the following cluster settings as needed:

        * **Service account**: [Service account](../../iam/concepts/users/service-accounts.md) of the Yandex Data Processing cluster.

            Select an existing service account or [create a new one](../../iam/operations/sa/create.md).

            To update a service account in a Yandex Data Processing cluster, [assign](../../iam/operations/roles/grant.md) the [iam.serviceAccounts.user](../../iam/security/index.md#iam-serviceAccounts-user) role or higher to your Yandex Cloud account.

            {% note warning %}
            
            If the cluster already uses a service account to access objects from Object Storage, then changing it to a different service account may make these objects unavailable and interrupt the cluster operation. Before changing the service account settings, make sure that the cluster doesn't use the objects in question.
            
            {% endnote %}

        * **Properties**: Cluster [component properties](../concepts/settings-list.md).

            Add, edit, or delete the properties as needed.

            {% note tip %}

            To include a property into the configuration file [related to a specific component](../concepts/settings-list.md#available-properties), specify a [prefix](../concepts/settings-list.md) for the key.

            {% endnote %}

        * **Bucket ID format**: Format for specifying the [bucket](../../storage/concepts/bucket.md) name, **List** or **ID**.

        * **Bucket name**: Name of the bucket that the cluster will use.

            Depending on the format you selected, either pick a name from the list or specify it manually. You can get the bucket name with the [list of buckets in the folder](../../storage/operations/buckets/get-info.md#get-information).

        * **Security groups**: [Security groups](../concepts/network.md#security-groups) that the cluster will use.

            Select one or more security groups. If the security group you need is missing from the list, [create it](../../vpc/operations/security-group-create.md).

            {% note warning %}

            Incorrect security group settings may cause performance issues in a Yandex Data Processing cluster. For more information on setting up security groups, see [this guide](security-groups.md).

            {% endnote %}

        * **UI Proxy**: Option that manages access to [component web interfaces](../concepts/interfaces.md) via [UI Proxy](connect-interfaces.md#ui-proxy).

            {% note warning %}
            
            For UI Proxy to work correctly, you need to establish network connectivity between your device, the cluster master node, and the UI Proxy servers.
            
            Make sure your device and the cluster master node are allowed outbound access to these service IP addresses:
            * `158.160.167.170`
            * `2a0d:d6c1:0:1c::23e`
            
            [Set up security groups](security-groups.md) if required.
            
            {% endnote %}

        * **Log group**: Yandex Cloud Logging [log group](../../logging/concepts/log-group.md) the cluster will send logs to.

            Select the default log group or another existing log group. If the log group you need is missing from the list, [create it](../../logging/operations/create-group.md).

            To enable the cluster to send logs, [assign](../../iam/operations/roles/grant.md) the `logging.writer` role to the cluster’s service account. For more information, see [this Yandex Cloud Logging guide](../../logging/security/index.md).

    1. In the advanced cluster settings, set **Deletion protection** as needed.

        This option manages cluster protection against accidental deletion by a user.

        Even with cluster deletion protection enabled, you can still connect to the cluster manually and delete the data.

    1. Click **Save changes**.

- 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.

    To change a Yandex Data Processing cluster’s settings:

    1. View the description of the CLI command for updating a cluster:

        ```bash
        yc dataproc cluster update --help
        ```

    1. To update the cluster's service account, provide the name or ID of the service account in the `--service-account-name` or `--service-account-id` parameter.

        ```bash
        yc dataproc cluster update <cluster_name_or_ID> \
           --service-account-id=<service_account_ID>
        ```

    1. To add or update the service account of [auto-scalable subclusters](../concepts/autoscaling.md), provide the name or ID of the service account in the `--autoscaling-service-account-name` or `--autoscaling-service-account-id` parameter.

        ```bash
        yc dataproc cluster update <cluster_name_or_ID> \
           --autoscaling-service-account-id=<service_account_ID>
        ```

    1. To edit the [log group](../../logging/concepts/log-group.md) the cluster logs go to, provide the log group ID in the `--log-group-id` parameter:

        ```bash
        yc dataproc cluster update <cluster_name_or_ID> \
           --log-group-id=<log_group_ID>
        ```

        You can get the log group ID with the [list of log groups in the folder](../../logging/operations/list.md).

    1. To protect your cluster against accidental deletion by a user of your cloud, provide the `--deletion-protection` parameter:

        ```bash
        yc dataproc cluster update <cluster_name_or_ID> \
           --deletion-protection
        ```

        Even with cluster deletion protection enabled, one can still connect to the cluster manually and delete its data.

    1. To update [component properties](../concepts/settings-list.md), provide the required properties in the `--property` parameter:

        ```bash
        yc dataproc cluster update <cluster_name_or_ID> \
           --property "<key_1_prefix>:<key_1>=<value>", "<key_2_prefix>:<key_2>=<value>", ...
        ```

        {% note warning %}

        The `--property` parameter will reset all component properties that you do not explicitly provide to their default values. To save the properties you updated earlier, list them in your request along with the ones you want to update.

        {% endnote %}

    You can get the cluster ID and name with the [list of clusters in the folder](cluster-list.md#list).

- Terraform {#tf}

    To change a Yandex Data Processing cluster’s settings:

    1. Open the current Terraform configuration file with the infrastructure plan.

        To learn how to create this file, refer to [Creating a cluster](cluster-create.md).

    1. To enable cluster deletion protection and access to the [web interfaces](../concepts/interfaces.md) of the Yandex Data Processing components, update the values of the appropriate fields in the Yandex Data Processing cluster description:

        ```hcl
        resource "yandex_dataproc_cluster" "data_cluster" {
          ...
          deletion_protection = true
          ui_proxy            = true
          ...
        }
        ```

    1. To update the service account of the Yandex Data Processing cluster, edit the `service_account_id` value in the Yandex Data Processing cluster description:

        ```hcl
        resource "yandex_dataproc_cluster" "data_cluster" {
          ...
          service_account_id = "<service_account_ID>"
          ...
        }
        ```

    1. To add or update a service account to manage [auto-scalable subclusters](../concepts/autoscaling.md), use the `autoscaling_service_account_id` argument in the Yandex Data Processing cluster description:

        ```hcl
        resource "yandex_dataproc_cluster" "data_cluster" {
          ...
          autoscaling_service_account_id = "<service_account_ID>"
          ...
        }
        ```

    1. Make sure the settings are correct.

        1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm resource changes.

        1. Run this command to view the planned changes:
        
           ```bash
           terraform plan
           ```
        
           If 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.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

    For more information about the resources you can create with Terraform, see [this provider guide](../../terraform/resources/dataproc_cluster.md).

{% endlist %}