Moving a subnet to a different folder
You can move subnets between folders within a single cloud.
- In the management console
, go to the folder with the subnet. - In the list of services, select Virtual Private Cloud.
- In the left-hand panel, select
Subnets. - In the line with the subnet, click
and select Move. - In the window that opens, select the destination folder.
- Click Move.
Note
Subnets can also be moved as part of a cloud network.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To move a subnet to another folder:
-
View a description of the CLI move subnet command:
yc vpc subnet move --help
-
Get the name or ID of the subnet to move:
yc vpc subnet list
Result:
+----------------------+----------+----------------------+----------------+---------------+------------------+ | ID | NAME | NETWORK ID | ROUTE TABLE ID | ZONE | RANGE | +----------------------+----------+----------------------+----------------+---------------+------------------+ | e9bcd5mq43cn******** | subnet-a | encb4ubvmief******** | | ru-central1-a | [10.1.0.0/16] | +----------------------+----------+----------------------+----------------+---------------+------------------+
-
Get a list of available folders:
yc resource-manager folder list
Result:
+----------------------+------------------------+--------+--------+ | ID | NAME | LABELS | STATUS | +----------------------+------------------------+--------+--------+ | b1cs8ie21pk1******** | default | | ACTIVE | | b1chgf288nvg******** | my-folder-1 | | ACTIVE | | b1cu6g9ielh6******** | my-folder-2 | | ACTIVE | +----------------------+------------------------+--------+--------+
-
Move the subnet by specifying the name or ID of the subnet and destination folder:
yc vpc subnet move <subnet_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 subnet is not in the current folder (default folder), specify the source folder using the
--folder-name
or--folder-id
option.Result:
id: e9bcd5mq43cn******** folder_id: b1chgf288nvg******** created_at: "2022-10-08T15:03:39Z" name: subnet-a network_id: encb4ubvmief******** zone_id: ru-central1-a v4_cidr_blocks: - 10.1.0.0/16 dhcp_options: {}
For more information about the
yc vpc subnet move
command, see the CLI reference.
To move a subnet to a different folder, use the move REST API method for the Subnet resource or the SubnetService/Move gRPC API call, and provide the following in the request:
-
ID of the subnet you need to move in the
subnetId
parameter.To get the subnet ID, use the list REST API method for the Subnet resource or the SubnetService/List gRPC API call and provide the folder ID in the
folderId
request parameter. -
ID of the folder you want to move the subnet to in the
destinationFolderId
parameter.To learn how to find out the folder ID, see Getting the folder ID.
Examples
Subnet in the current folder
Move a subnet from the current folder by specifying the subnet name and destination folder name:
yc vpc subnet move subnet-a \
--destination-folder-name my-folder-1
Subnet in a different folder
Move a subnet from a different folder. Specify the subnet ID and the source and destination folder IDs:
yc vpc subnet move enc39op1vq9m******** \
--folder-id b1chgf288nvg******** \
--destination-folder-id b1cs8ie21pk1********