Updating a cloud network
After creating a cloud network, you can change its name, description, and labels.
- In the management console
, go to the folder where you need to update a cloud network. - In the list of services, select Virtual Private Cloud.
- Click
in the row of the subnet you need and select Edit. - Edit as appropriate.
- Click Save changes.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
-
See the description of the CLI command for updating cloud network parameters:
yc vpc network update --help -
Get a list of all networks in the default folder:
yc vpc network listResult:
+----------------------+----------------+ | ID | NAME | +----------------------+----------------+ | enpavfmgapum******** | test-network-1 | | enplom7a98s1******** | default | +----------------------+----------------+ -
Select the
IDorNAMEof the network you need. -
Change the parameters of the cloud network by specifying its name:
yc vpc network update enpavfmgapum******** --new-name test-network-renamedResult:
id: enpavfmgapum******** folder_id: b1g6ci08ma55******** created_at: "2018-10-23T14:05:32Z" name: test-network-renamed description: My first network labels: new_label: test_labelYou can provide the ID and name not only as positional arguments, but also using the
--idand--nameparameters:yc vpc network update \ --id enpavfmgapum******** \ --new-name test-network-renamed \ --labels new_label=test_labelyc vpc network update \ --name test-network-1 \ --new-name test-network-renamed \ --labels new_label=test_label
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
-
Open the Terraform configuration file and edit the fragment with the cloud network description:
# Example of a cloud network description resource "yandex_vpc_network" "default" { name = "network-1" description = "My first network" labels = { tf-label = "tf-label-value" empty-label = "" } }For more information about
yandex_vpc_networkproperties, see this Terraform article. -
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
You can check the cloud network update using the management console
or the following CLI command:yc vpc network get <network_name> -
To update a cloud network, use the update REST API method for the Network resource or the NetworkService/Update gRPC API call, and provide the following in the request:
-
ID of the cloud network you want to update, in the
networkIdparameter.To get the cloud network ID, use the list REST API method for the Network resource or the NetworkService/List gRPC API call and provide the folder ID in the
folderIdrequest parameter.To learn how to find out the folder ID, see Getting the folder ID.
-
New network settings, if required:
- Name in the
nameparameter. - Description in the
descriptionparameter. - Network labels in the
labelsparameter.
- Name in the
-
List of settings to update in the
updateMaskparameter.
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.
Examples
Updating a cloud network using its name
You can update a cloud network using its name instead of its ID:
yc vpc network update test-network-1 \
--new-name test-network-renamed \
--labels new_label=test_label
Result:
id: enpavfmgapum********
folder_id: b1g6ci08ma55********
created_at: "2018-10-23T14:05:32Z"
name: test-network-renamed
description: My first network
labels:
new_label: test_label