[Yandex Cloud documentation](../../index.md) > [Yandex Virtual Private Cloud](../index.md) > [Step-by-step guides](index.md) > Static routing > Moving a NAT gateway between folders

# Moving a NAT gateway to a different folder

{% note info %}

The feature is at the [Preview stage](../../overview/concepts/launch-stages.md).

{% endnote %}

You can move cloud resources between folders within a single [cloud](../../resource-manager/concepts/resources-hierarchy.md).

{% list tabs group=instructions %}

- Management console {#console}

  To move a [NAT gateway](../concepts/gateways.md) to a different folder:

  1. In the [management console](https://console.yandex.cloud), select the folder containing the NAT gateway.
  1. Navigate to **Virtual Private Cloud**.
  1. In the left-hand panel, select ![image](../../_assets/console-icons/arrows-opposite-to-dots.svg) **Gateways**.
  1. Click ![image](../../_assets/console-icons/ellipsis.svg) in the row of the NAT gateway to move and select **Move**.
  1. Select the destination folder from the drop-down list.
  1. Click **Move**.

- 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 move a [NAT gateway](../concepts/gateways.md) to a different folder:

  1. View the description of the CLI command for moving a NAT gateway:

      ```bash
      yc vpc gateway move --help
      ```

  1. Get the name or ID of the NAT gateway to move:

      ```bash
      yc vpc gateway list
      ```
      Result:
      ```text
      +----------------------+----------+-------------+
      |          ID          |   NAME   | DESCRIPTION |
      +----------------------+----------+-------------+
      | enckq19qqsr5******** | router-1 |             |
      +----------------------+----------+-------------+
      ```

  1. Get a list of available folders:

      ```bash
      yc resource-manager folder list
      ```

      Result:
      ```text
      +----------------------+------------------------+--------+--------+
      |          ID          |          NAME          | LABELS | STATUS |
      +----------------------+------------------------+--------+--------+
      | b1cs8ie21pk1******** | default                |        | ACTIVE |
      | b1chgf288nvg******** | my-folder-1            |        | ACTIVE |
      | b1cu6g9ielh6******** | my-folder-2            |        | ACTIVE |
      +----------------------+------------------------+--------+--------+
      ```

  1. Move the NAT gateway by specifying the name or ID of the NAT gateway and destination folder:

     ```bash
     yc vpc gateway move <gateway_name_or_ID> \
       --destination-folder-name <destination_folder_name> \
       --destination-folder-id <destination_folder_ID>
     ```
     Use either `--destination-folder-name` or `--destination-folder-id`.

     If the gateway is not in the current folder (default folder), specify the source folder using `--folder-name` or `--folder-id`.

     Result:
     ```text
     id: enckq19qqsr5********
     folder_id: b1chgf288nvg********
     created_at: "2022-10-06T10:14:04Z"
     name: router-1
     shared_egress_gateway: {}
     ```
     For more information about the `yc vpc address move` command, see the [CLI reference](../../cli/cli-ref/vpc/cli-ref/gateway/move.md).

- API {#api}

  To move a [NAT gateway](../concepts/gateways.md) to a different folder, use the [move](../api-ref/Gateway/move.md) REST API method for the [Gateway](../api-ref/Gateway/index.md) resource or the [GatewayService/Move](../api-ref/grpc/Gateway/move.md) gRPC API call, and provide the following in the request:

  * ID of the NAT gateway to move, in the `gatewayId` parameter.

    To get the NAT gateway ID, use the [list](../api-ref/Gateway/list.md) REST API method for the [Gateway](../api-ref/Gateway/index.md) resource or the [GatewayService/List](../api-ref/grpc/Gateway/list.md) gRPC API call. In your request, provide the folder ID in the `folderId` parameter.

  * ID of the folder you want to move the NAT gateway to, in the `destinationFolderId` parameter.

    To learn how to find out the folder ID, see [Getting the folder ID](../../resource-manager/operations/folder/get-id.md).

{% endlist %}

## Examples {#examples}

### NAT gateway in a different folder {#from-another-folder}

Move a NAT gateway from a different folder. Specify the NAT gateway ID and the source and destination folder IDs:

{% list tabs group=instructions %}

- CLI {#cli}

  ```bash
  yc vpc gateway move enckq19qqsr5******** \
    --folder-id b1chgf288nvg******** \
    --destination-folder-id b1cs8ie21pk1********
  ```

{% endlist %}

#### Useful links {#see-also}

* [Moving a cloud network to a different folder](network-move.md)
* [Moving a subnet to a different folder](subnet-move.md)