[Yandex Cloud documentation](../../index.md) > [Yandex Network Load Balancer](../index.md) > [Step-by-step guides](index.md) > Network load balancers > Changing load balancer settings

# Changing network load balancer settings

{% note info %}

You can only set the load balancer type (internal or external) when creating it and cannot change it later.

{% endnote %}

After you create a network load balancer, you can:

* [Change the load balancer name and description](#change-name-and-description).
* [Change load balancer labels](#change-labels).
* [Change the target group or its health check settings](#change-target-group).
* [Connect a target group](#add-target-group).
* [Add a listener](#add-listener).

## Changing a load balancer name and description {#change-name-and-description}

{% list tabs group=instructions %}

- Management console {#console}

    1. Navigate to **Network Load Balancer**.
    1. Select a load balancer and click **Edit** at the top of the page.
    1. Enter a new name and description for the load balancer.
    1. Click **Edit**.

- 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 the name and description of a load balancer:

    1. Find out the ID or name of the load balancer by getting a [list of network load balancers in the folder](load-balancer-list.md#list).

    1. View the current `name` and `description` of the load balancer:

        ```bash
        yc load-balancer network-load-balancer get <load_balancer_name_or_ID>
        ```

    1. See the description of the CLI command for changing load balancer configuration:

        ```bash
        yc load-balancer network-load-balancer update --help
        ```

    1. Set a new name and description for the load balancer:

        ```bash
        yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \
           --new-name=<new_load_balancer_name> \
           --description=<new_load_balancer_description>
        ```

- Terraform {#tf}

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

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

        For a complete list of updatable network load balancer configuration fields, see [this provider guide](../../terraform/resources/lb_network_load_balancer.md).

    1. In the network load balancer description, change the `name` and `description` values:

        ```hcl
        resource "yandex_lb_network_load_balancer" "foo" {
          name        = "<load_balancer_name>"
          description = "<load_balancer_description>"
          ...
        ```

    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 updating the resources.

        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 [update](../api-ref/NetworkLoadBalancer/update.md) API method, providing the following in your request:

    * Load balancer ID in the `networkLoadBalancerId` parameter. To find out the ID, [get a list of network load balancers in the folder](load-balancer-list.md#list).
    * New name in the `name` parameter.
    * New description in the `description` parameter.
    * List of cluster configuration fields to update, in the `updateMask` parameter (in this case, `name` and `description`).

    {% note warning %}
    
    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
    
    {% endnote %}

{% endlist %}

## Changing load balancer labels {#change-labels}

{% list tabs group=instructions %}

- Management console {#console}

    1. Navigate to **Network Load Balancer**.
    1. Select a load balancer and click **Edit** at the top of the page.
    1. Change the load balancer labels.
    1. Click **Edit**.

- 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 the labels of a network load balancer:

    1. View the current load balancer `labels` and their values:

        ```bash
        yc load-balancer network-load-balancer get <load_balancer_name_or_ID>
        ```

        You can get the load balancer ID and name with the [list of network load balancers in the folder](load-balancer-list.md#list).

    1. See the description of the CLI command for changing load balancer configuration:

        ```bash
        yc load-balancer network-load-balancer update --help
        ```

    1. Set new values for the load balancer labels:

        ```bash
        yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \
           --labels <key_1>=<value_1>,<key_2>=<value_2>,...
        ```

- Terraform {#tf}

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

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

        For a complete list of updatable network load balancer configuration fields, see [this provider guide](../../terraform/resources/lb_network_load_balancer.md).

    1. In the network load balancer description, change the `name` and `description` values:

        ```hcl
        resource "yandex_lb_network_load_balancer" "foo" {
          ...
          labels = {
            <key_1> = "<value_1>"
            <key_2> = "<value_2>"
            ...
          }
          ...
        ```

    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 updating the resources.

        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 [update](../api-ref/NetworkLoadBalancer/update.md) API method, providing the following in your request:

    * Load balancer ID in the `networkLoadBalancerId` parameter. To find out the ID, [get a list of network load balancers in the folder](load-balancer-list.md#list).
    * New label values in the `labels` parameter.
    * List of cluster configuration fields to update, in the `updateMask` parameter (in this case, `labels`).

    {% note warning %}
    
    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
    
    {% endnote %}

{% endlist %}

## Changing a target group or its health check settings {#change-target-group}

{% list tabs group=instructions %}

- Management console {#console}

    1. Navigate to **Network Load Balancer**.
    1. Select a load balancer and click **Edit** at the top of the page.
    1. Under **Target groups**, select a different target group from the drop-down list or [create a new one](target-group-create.md).
    1. To change target group health check settings:
        1. In the section with the target group in question, click **Configure**.
        1. Specify new target group health check settings.
        1. Click **Apply**.
    1. Click **Edit**.

- 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 target group or its health check settings:

    1. See the description of the CLI command for changing load balancer configuration:

        ```bash
        yc load-balancer network-load-balancer update --help
        ```

    1. Specify the target group's new ID and health check settings:

        ```bash
        yc load-balancer network-load-balancer update <load_balancer_name_or_ID> \
           --target-group target-group-id=<target_group_ID>,`
                         `healthcheck-name=<health_check_name>,`
                         `healthcheck-interval=<health_check_interval>s,`
                         `healthcheck-timeout=<response_timeout>s,`
                         `healthcheck-unhealthythreshold=<number_of_failed_checks_to_get_Unhealthy_status>,`
                         `healthcheck-healthythreshold=<number_of_successful_checks_to_get_Healthy_status>,`
                         `healthcheck-tcp-port=<TCP_port>,`
                         `healthcheck-http-port=<HTTP_port>,`
                         `healthcheck-http-path=<URL>
        ```

        Where:

        * `--target-group`: Target group parameters and [health check](../concepts/health-check.md) settings:
            * `target-group-id`: Target group ID.
        
              To find out the ID, [get](target-group-list.md#list) a list of target groups in the folder.
        
            * `healthcheck-name`: Health check name.
            * `healthcheck-interval`: Health check interval in seconds. The possible values range from `1s` to `60s`. The interval must be at least 1 second longer than the response timeout. 
            * `healthcheck-timeout`: Response timeout in seconds. The possible values range from `1s` to `60s`.
            * `healthcheck-unhealthythreshold`: Number of failed checks before traffic is no longer routed to the VM. The possible values range from `2` to `10`.
            * `healthcheck-healthythreshold`: Number of successful checks required to consider the VM ready to receive traffic. The possible values range from `2` to `10`.
            * `healthcheck-tcp-port`: Port for TCP health checks. The possible values range from `1` to `32,767`.
            * `healthcheck-http-port`: Port for HTTP health checks. The possible values range from `1` to `32,767`.
            * `healthcheck-http-path`: URL for HTTP health checks.
        
            You cannot specify both `healthcheck-tcp-port` and `healthcheck-http-port` at the same time.
        
            {% note warning %}
            
            Use the `<time_in_seconds>s` format, e.g., `20s`, for the `healthcheck-interval` and `healthcheck-timeout` values.
            
            {% endnote %}

        You can get the load balancer ID and name with the [list of network load balancers in the folder](load-balancer-list.md#list).

- Terraform {#tf}

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

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

        For a complete list of updatable network load balancer configuration fields, see [this provider guide](../../terraform/resources/lb_network_load_balancer.md).

    1. In the network load balancer description, change the target group ID and its health check settings under `attached_target_group`:

        ```hcl
        resource "yandex_lb_network_load_balancer" "foo" {
          name = "<load_balancer_name>"
          ...
          attached_target_group {
            target_group_id = "<target_group_ID>"
            healthcheck {
              name = "<health_check_name>"
              http_options {
                port = <port_number>
                path = "<URL>"
              }
            }
          }
          ...
        }
        ```

        Where:

        * `name`: Name of the network load balancer.
        * `attached_target_group`: Description of the network load balancer's target group settings:
            * `target_group_id`: Target group ID.

              To find out the ID, [get](target-group-list.md#list) a list of target groups in the folder.

            * `healthcheck`: Health check settings. Specify a name, a port number ranging from `1` to `32767`, and a path for health checks.

    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 updating the resources.

        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 [update](../api-ref/NetworkLoadBalancer/update.md) API method, providing the following in your request:

    * Load balancer ID in the `networkLoadBalancerId` parameter. To find out the ID, [get a list of network load balancers in the folder](load-balancer-list.md#list).
    * Target group ID and health check settings in the `attachedTargetGroups` parameter.

      To find out the ID, [get](target-group-list.md#list) a list of target groups in the folder.

    * List of cluster configuration fields to update, in the `updateMask` parameter (in this case, `attachedTargetGroups`).

    {% note warning %}
    
    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the `updateMask` parameter as a single comma-separated string.
    
    {% endnote %}

{% endlist %}

## Attaching a target group {#add-target-group}

To attach a target group, follow [this guide](target-group-attach.md).

## Adding a listener {#add-listener}

To add a listener, follow [this guide](listener-add.md).