Deleting a cloud network
Alert
Before deleting a network, you need to delete all its child resources.
You cannot restore a network after it is deleted.
To delete a cloud network:
- In the management console
, go to the folder where you need to delete a cloud network. - In the list of services, select Virtual Private Cloud.
- Click
in the row of the network you need and select Delete. - In the window that opens, click Delete.
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.
-
View the description of the CLI command for deleting cloud networks:
yc vpc network delete --help
-
Get a list of all networks in the default folder:
yc vpc network list
Result:
+----------------------+----------------+ | ID | NAME | +----------------------+----------------+ | enpiuvhhd4t8******** | test-network-1 | | enplom7a98s1******** | default | +----------------------+----------------+
-
Select the network
ID
orNAME
. -
Delete the network:
yc vpc network delete test-network-1
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
To delete a cloud network created with Terraform:
-
Open the Terraform configuration file and delete the fragment with the cloud network description.
Example of a cloud network description in the Terraform configuration
... resource "yandex_vpc_network" "default" { name = "network-1" description = "My first network" labels = { tf-label = "tf-label-value" empty-label = "" } } ...
-
In the command line, navigate to the directory with the Terraform configuration file.
-
Check the configuration using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the changes:
terraform apply
-
Type
yes
and press Enter to confirm changes.You can check the update using the management console
or these CLI commands:yc vpc network list
To delete a cloud network, use the delete REST API method for the Network resource or the NetworkService/Delete gRPC API call, and provide the ID of the cloud network to delete in the networkId
request parameter.
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 folderId
request parameter.
To learn how to find out the folder ID, see Getting the folder ID.