[Yandex Cloud documentation](../../index.md) > [Yandex MetaData Hub](../index.md) > Connection Manager > Step-by-step guides > Editing a connection

# Editing a connection


To change connection settings:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select a [folder](../../resource-manager/concepts/resources-hierarchy.md#folder).
  1. [Navigate](../../console/operations/select-service.md#select-service) to **Yandex MetaData Hub**.
  1. In the left-hand panel, select ![image](../../_assets/console-icons/plug-connection.svg) **Connection manager**.
  1. In the list of connections, click ![image](../../_assets/console-icons/ellipsis.svg) to the right of the connection you want to edit.
  1. Select **Edit**.
  1. Change the required connection parameters, such as description, labels, database server settings, or user authentication information.
  1. Click **Apply** to save the 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.

  You can update settings of a connection to a cluster with a managed database or to a custom database installation.

  1. To update settings of a connection to a cluster with a managed database:

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

          ```bash
          yc metadata-hub connection-manager connection update <database_type> --help
          ```

          The supported database types are `postgresql`, `mysql`, `clickhouse`, `mongodb`, `opensearch`, `valkey`, `greenplum`, and `kafka`.

      1. Update your connection by running this command:
      
          ```bash
          yc metadata-hub connection-manager connection update <database_type> <connection_ID> \
            --name <connection_name> \
            --user <username> \
            --password <password> \
            --managed-cluster-id <cluster_ID>
          ```

          Where:

          * `--name`: Connection name.

          * `--user`: Username to connect to the cluster.

          * `--password`: Password.
      
          * `--managed-cluster-id`: Cluster ID. You can get the cluster ID with the list of clusters in the folder.

          You can get the connection ID with the [list of connections](view-connection.md#connection-list) in the folder.

      1. You can update the list of databases for all connections, except Managed Service for OpenSearch and Managed Service for Apache Kafka® connections, by running this command:

          ```bash
          yc metadata-hub connection-manager connection update <database_type> <connection_ID> \
            --databases <database_list>
          ```

          Where `--databases` is a comma-separated list of databases.
          
          Make sure the user has the required access permissions.
  
  1. To update settings of a connection to a custom database installation:
      
      1. View the description of the CLI command for updating a connection:

          ```bash
          yc metadata-hub connection-manager connection update <database_type> --help
          ```

          The supported database types are `postgresql`, `mysql`, `clickhouse`, `mongodb`, `redis`, `opensearch`, `trino`, `valkey`, `greenplum`, and `kafka`.

      1. Update your connection by running this command:
      
          ```bash
          yc metadata-hub connection-manager connection update <database_type> <connection_ID> \
            --name <connection_name> \
            --user <username> \
            --password <password> \
            --ca-certificate <path_to_certificate>
          ```

          Where:

          * `--name`: Connection name.
          
          * `--description`: Connection description.
          
          * `--labels`: Comma-separated list of labels in `"<key>":"<value>"` format.
          
          * `--user`: Username to connect to the cluster.
          
          * `--password`: Password.
          
          * `--ca-certificate`: Path to your TLS CA certificate file.
          
            TLS is enabled by default; to disable it, use the `--tls-disabled` flag.

      1. You can also update the following:

          * List of hosts for all connections, except Trino connections, by running this command:

            ```bash
            yc metadata-hub connection-manager connection update <database_type> <connection_ID> \
              --hosts <list_of_hosts>
            ```

            Where `--hosts` is a comma-separated list of hosts.

            {% note warning %}

            Host notation format depends on the database type. For more information, see the [CLI reference](../../cli/cli-ref/metadata-hub/cli-ref/connection-manager/connection/update/index.md).

            {% endnote %}

          * Coordinator parameters for connecting to Trino, by running this command:

            ```bash
            yc metadata-hub connection-manager connection update trino <connection_ID> \
              --coordinator <coordinator_parameters>
            ```

            Where `--coordinator` stands for coordinator parameters in `<host>:<port>` format.

          * List of databases for all connections, except Trino, OpenSearch, and Apache Kafka® connections, by running this command:

            ```bash
            yc metadata-hub connection-manager connection update <database_type> <connection_ID> \
              --databases <database_list>
            ```

            Where `--databases` is a comma-separated list of databases.
          
            Make sure the user has the required access permissions.


- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the guides on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../terraform/index.md).
  
  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.

  {% note alert %}

  Do not change the connection name using Terraform. This will delete the existing connection and create a new one.

  {% endnote %}

  You can update settings of a connection to a cluster with a managed database or to a custom database installation.

  1. To update settings of a connection to a cluster with a managed database:

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

      1. To update the description and labels for a connection, update the values of the relevant fields in the resource description:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            description = "<connection_description>"
        
            labels = {
              "<key_1>" = "<value_1>"
              "<key_2>" = "<value_2>"
              ...
              "<key_N>" = "<value_N>"
            }
            ...
          }
          ```

          Where:

          * `description`: Connection description.

          * `--labels`: Labels in `"<key>" = "<value>"` format.

      1. To update the cluster ID, update the `managed_cluster_id` field value under `params.<database_type>`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                managed_cluster_id = "<cluster_ID>"
                ...
              }
            }
          }
          ```

      1. To update the list of databases for all connections, except Managed Service for OpenSearch and Managed Service for Apache Kafka® connections, update the `databases` field value under `params.<database_type>`:
     
          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                ...
                databases = [
                  "<database_1>",
                  "<database_2>",
                  ...
                  "<database_N>"
                ]
                ...
              }
            }
          }
          ```

          Where `databases` is the list of databases. Make sure the user has the required access permissions.

      1. To update authentication parameters for all connections, except Managed Service for Apache Kafka® connections, update the values in the `user` and `password.raw` fields under `params.<database_type>.auth.user_password`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                ...
                auth = {
                  user_password = {
                    user     = "<username>"
                    password = {
                      raw = "<password>"
                    }
                  }
                }
              }
            }
          }
          ```
      
      1. To update authentication parameters for Managed Service for Apache Kafka® connections, update the values of the fields under `params.kafka.auth.sasl`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              kafka = {
                ...
                auth = {
                  sasl = {
                    user     = "<username>"
                    password = { 
                      raw = "<password>"
                    }
                    supported_mechanisms = [
                      <list_of_authentication_mechanisms>
                    ]
                  }
                }
              }
            }
          }
          ```

          Where `params.kafka.auth` stands for authentication parameters. Select one of the sections:

          * `sasl`: SASL authentication parameters.
            
            * `user`: Username to connect to the cluster.
            * `password.raw`: Password.
            * `supported_mechanisms`: List of authentication mechanisms. The possible values are:
              
              * `PLAIN`: Authentication with login and password provided as plain unencrypted text.
              * `SCRAM_SHA256`: Authentication with SHA-256 hashing.
              * `SCRAM_SHA512`: Authentication with SHA-512 hashing.

          
          * `disabled`: Disables authentication.
  
      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.
  
  1. To update settings of a connection to a custom database installation:

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

      1. To update the description and labels for a connection, update the values of the relevant fields in the resource description:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            description = "<connection_description>"
        
            labels = {
              "<key_1>" = "<value_1>"
              "<key_2>" = "<value_2>"
              ...
              "<key_N>" = "<value_N>"
            }
            ...
          }
          ```

          Where:

          * `description`: Connection description.

          * `--labels`: Labels in `"<key>" = "<value>"` format.

      1. To update the list of hosts for all connections, except Trino connections, update the `hosts` field value under `params.<database_type>.cluster`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                cluster = {
                  hosts = [
                    {
                      <host_1_parameters>
                    },
                    {
                      <host_2_parameters>
                    },
                    ...
                    {
                      <host_N_parameters>
                    }
                  ]
                  ...
                }
                ...
              }
            }
          }
          ```

          {% note warning %}

          Host parameters depend on the database type. For more information, see [this Terraform provider guide](https://terraform-provider.yandexcloud.net/resources/connectionmanager_connection).

          {% endnote %}

      1. To update coordinator parameters for Trino connections, update the values of the `host` and `port` fields under `params.trino.cluster.coordinator`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                cluster = {
                  coordinator = {
                    host = "<host>"
                    port = <port>
                  }
                  ...
                }
                ...
              }
            }
          }
          ```

      1. To update TLS parameters, update the field values under `params.<database_type>.cluster.tls_params`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                cluster = {
                  ...
                  tls_params = {
                    tls {
                      ca_certificate = "<path_to_certificate>"
                    }
                  }
                }
                ...
              }
            }
          }
          ```

          Where `params.<database_type>.cluster.tls_params` represents TLS parameters. Select one of the sections:
        
          * `tls.ca_certificate`: Path to your TLS CA certificate file.
          * `disabled`: Disables TLS. TLS is enabled by default.

      1. To update the list of databases for all connections, except Trino, OpenSearch, and Apache Kafka® connections, update the `databases` field value under `params.<database_type>`:
     
          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                ...
                databases = [
                  "<database_1>",
                  "<database_2>",
                  ...
                  "<database_N>"
                ]
                ...
              }
            }
          }
          ```

          Where `databases` is the list of databases. Make sure the user has the required access permissions.
  
      1. To update authentication parameters for all connections, except Apache Kafka® connections, update the values in the `user` and `password.raw` fields under `params.<database_type>.auth.user_password`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              <database_type> = {
                ...
                auth = {
                  user_password = {
                    user     = "<username>"
                    password = {
                      raw = "<password>"
                    }
                  }
                }
              }
            }
          }
          ```
      
      1. To update authentication parameters for Apache Kafka® connections, update the values of the fields under `params.kafka.auth.sasl`:

          ```hcl
          resource "yandex_connectionmanager_connection" "<local_connection_name>" {
            ...
            params = {
              kafka = {
                ...
                auth = {
                  sasl = {
                    user     = "<username>"
                    password = { 
                      raw = "<password>"
                    }
                    supported_mechanisms = [
                      <list_of_authentication_mechanisms>
                    ]
                  }
                }
              }
            }
          }
          ```

          Where `params.kafka.auth` stands for authentication parameters. Select one of the sections:

          * `sasl`: SASL authentication parameters.
            
            * `user`: Username to connect to the cluster.
            * `password.raw`: Password.
            * `supported_mechanisms`: List of authentication mechanisms. The possible values are:
              
              * `PLAIN`: Authentication with login and password provided as plain unencrypted text.
              * `SCRAM_SHA256`: Authentication with SHA-256 hashing.
              * `SCRAM_SHA512`: Authentication with SHA-512 hashing.

          
          * `disabled`: Disables authentication.

      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.
  
      
- API {#api}

  Use the [Connection.Update](../connection-manager/api-ref/Connection/update.md) REST API method or the [ConnectionService.Update](../connection-manager/api-ref/grpc/Connection/update.md) gRPC API call and provide the connection ID in the request.

  You can get the connection ID with the [list of connections](view-connection.md#connection-list) in the folder.

{% endlist %}