[Yandex Cloud documentation](../../../index.md) > [Yandex Network Load Balancer](../../index.md) > [Step-by-step guides](../index.md) > Network load balancers > Managing availability zones > Allowing and denying zonal shift

# Allowing or denying zonal shift

If an [availability zone](../../../overview/concepts/geo-scope.md) is under maintenance or has technical problems, you can configure Yandex Cloud to automatically prohibit your load balancer from sending traffic to that zone. This will ensure your services stay operational. Once the zone is recovered, traffic will once again be routed to all the zones configured for the load balancer.

You can also manually enable or disable specific availability zones and [test zonal shift](disable-enable-zone.md) from any of them. After the test, you can allow zonal shift only for specific load balancers.

By default, zonal shift is not allowed.


## Allowing zonal shift {#allow}

{% list tabs group=instructions %}

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

  When [creating](../load-balancer-create.md) or [updating](../load-balancer-update.md) a network load balancer, set the `--allow-zonal-shift` parameter, for example:

    ```bash
    yc load-balancer network-load-balancer update \
      <load_balancer_name_or_ID> \
      --allow-zonal-shift
    ```

    Result:

    ```text
    id: ds70q425egoe********
    name: my-balancer
    ...
    allow_zonal_shift: true
    ```

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

  1. In the configuration file, specify the `allow_zonal_shift` parameter set to `true` in the `yandex_lb_network_load_balancer` resource description:

      ```hcl
      resource "yandex_lb_network_load_balancer" "my-balancer" {
        ...
        allow_zonal_shift = true
        ...
      }
      ```

  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.

      Terraform will update all required resources. You can check the resource update using this [CLI](../../../cli/quickstart.md) command:

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

  For more on the properties of the `yandex_lb_network_load_balancer` resource, see [this provider guide](../../../terraform/data-sources/lb_network_load_balancer.md).

- API {#api}

  To allow zonal shift when creating a network load balancer, use the [create](../../api-ref/NetworkLoadBalancer/create.md) REST API method for the [NetworkLoadBalancer](../../api-ref/NetworkLoadBalancer/index.md) resource and set `"allowZonalShift": "true"`, or use the [NetworkLoadBalancerService/Create](../../api-ref/grpc/NetworkLoadBalancer/create.md) gRPC API call and set `"allow_zonal_shift": "true"`.

  To allow zonal shift when updating a network load balancer, use the [update](../../api-ref/NetworkLoadBalancer/update.md) REST API method for the [NetworkLoadBalancer](../../api-ref/NetworkLoadBalancer/index.md) resource and set `"allowZonalShift": "true"`, or use the [NetworkLoadBalancerService/Update](../../api-ref/grpc/NetworkLoadBalancer/update.md) gRPC API call and set `"allow_zonal_shift": "true"`.

{% endlist %}


## Denying zonal shift {#deny}

{% list tabs group=instructions %}

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

  When creating or updating a network load balancer, set `--allow-zonal-shift=false`, for example:

    ```bash
    yc load-balancer network-load-balancer update \
      <load_balancer_name_or_ID> \
      --allow-zonal-shift=false
    ```

    Result:

    ```text
    id: ds70q425egoe********
    name: my-balancer
    ...
    ```

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

  1. In the configuration file, specify the `allow_zonal_shift` parameter set to `false` in the `yandex_lb_network_load_balancer` resource description:

      ```hcl
      resource "yandex_lb_network_load_balancer" "my-balancer" {
        ...
        allow_zonal_shift = false
        ...
      }
      ```

  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.

      Terraform will update all required resources. You can check the resource update using this [CLI](../../../cli/quickstart.md) command:

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

  For more on the properties of the `yandex_lb_network_load_balancer` resource, see [this provider guide](../../../terraform/data-sources/lb_network_load_balancer.md).

- API {#api}

  To deny zonal shift when creating a network load balancer, use the [create](../../api-ref/NetworkLoadBalancer/create.md) REST API method for the [NetworkLoadBalancer](../../api-ref/NetworkLoadBalancer/index.md) resource and set `"allowZonalShift": "false"`, or use the [NetworkLoadBalancerService/Create](../../api-ref/grpc/NetworkLoadBalancer/create.md) gRPC API call and set `"allow_zonal_shift": "false"`.

  To deny zonal shift when updating a network load balancer, use the [update](../../api-ref/NetworkLoadBalancer/update.md) REST API method for the [NetworkLoadBalancer](../../api-ref/NetworkLoadBalancer/index.md) resource and set `"allowZonalShift": "false"`, or use the [NetworkLoadBalancerService/Update](../../api-ref/grpc/NetworkLoadBalancer/update.md) gRPC API call and set `"allow_zonal_shift": "false"`.

{% endlist %}


#### What's next {whats-next}

* [Enabling and disabling availability zones](disable-enable-zone.md)