Deleting a route table
If you no longer need a route table, you can delete it. Before deleting a table, disassociate it from all subnets it is associated with.
Disassociating a route table from a subnet
-
In the management console
, go to the folder where you need to disassociate a route table. -
In the list of services, select Virtual Private Cloud.
-
Go to the cloud network the route table belongs to.
Note
If you do not know which network the route table belongs to, in the left-hand panel, select
Routing tables. This will open a list of route tables. Find the network you need in the Network column next to the route table name. To view the cloud network, click its name. -
In the list of subnets, find the subnet associated with the route table.
-
Disassociate the route table from the subnet using any of these methods:
- In the row with subnet information, click
next to the route table name. - In the row with subnet information, click
and select Edit. In the window that opens, click in the row with the route table name and save the changes. - Open the subnet information and click
next to the route table name. - Open the subnet information and click Edit in the top right corner. In the window that opens, click
in the row with the route table name and save the changes.
- In the row with subnet information, click
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 disassociate a route table from a subnet:
-
View the description of the CLI command for updating subnet parameters:
yc vpc subnet update --help
-
Get the name or ID of the subnet the route table is associated with:
yc vpc subnet list
Result:
+----------------------+----------------------------+----------------------+----------------------+---------------+-----------------+ | ID | NAME | NETWORK ID | ROUTE TABLE ID | ZONE | RANGE | +----------------------+----------------------------+----------------------+----------------------+---------------+-----------------+ | e9b4vdgv0v1n******** | default-ru-central1-a | enptgj64mv2r******** | | ru-central1-a | [10.128.0.0/24] | | e2lp11c4o77d******** | default-ru-central1-b | enptgj64mv2r******** | enpcaaqahk3c******** | ru-central1-b | [10.129.0.0/24] | +----------------------+----------------------------+----------------------+----------------------+---------------+-----------------+
-
Disassociate the route table from the subnet:
yc vpc subnet update <subnet_name_or_ID> --disassociate-route-table
Use either the
--id
or--name
parameter.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
To disassociate a route table from a subnet in the infrastructure created in Terraform:
-
Open the Terraform configuration file and find the section with the description of the subnet associated with the route table:
Example subnet description in the Terraform configuration
... resource "yandex_vpc_subnet" "subnet" { folder_id = "<user_folder_ID>" name = "<subnet_name>" v4_cidr_blocks = ["10.20.30.0/24"] zone = "<availability_zone>" network_id = "<subnet_ID>" route_table_id = "<route_table_ID>" } ...
-
Delete the route table description string from this section:
route_table_id = "<route_table_ID>"
-
In the command line, go 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
The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.You can check the update using the management console
or this CLI command:yc vpc subnet get <subnet_name_or_ID>
Use either the
--id
or--name
parameter.
To disassociate a route table from a subnet, use the update REST API method for the Subnet resource or the SubnetService/Update gRPC API call and provide an empty string in the following request parameters:
routeTableId
: For REST APIroute_table_id
: For gRPC API
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.
Deleting a route table
Warning
Before deleting a table, disassociate it from all subnets it is associated with.
To delete a route table:
- In the management console
, go to the folder where you need to delete a route table. - In the list of services, select Virtual Private Cloud.
- In the left-hand panel, select
Routing tables. - Click
in the row with the appropriate table name and select Delete. - In the window that opens, click Delete.
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 delete a route table:
-
View the description of the CLI command for deleting a route table:
yc vpc route-table delete --help
-
Get the name or ID of the route table to delete:
yc vpc route-table list
Result:
+----------------------+---------+-------------+----------------------+ | ID | NAME | DESCRIPTION | NETWORK-ID | +----------------------+---------+-------------+----------------------+ | enpd3s8svtkd******** | table-1 | | enptgj64mv2r******** | +----------------------+---------+-------------+----------------------+
-
Delete the route table:
yc vpc route-table delete <route_table_name_or_ID>
Use either the
--id
or--name
parameter.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
To delete a route table created using Terraform:
-
Open the Terraform configuration file and remove the section with the route table description.
Example of a table description in the Terraform configuration
... resource "yandex_vpc_route_table" "route_table" { folder_id = "<user_folder_ID>" name = "<route_table_name>" network_id = "<network_ID>" static_route { destination_prefix = "10.2.0.0/16" next_hop_address = "172.16.10.10" } } ...
-
In the command line, go 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
The terminal will display a list of resources with parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.You can check the update using the management console
or this CLI command:yc vpc subnet list
To delete a route table, use the delete REST API method for the RouteTable resource or the RouteTableService/Delete gRPC API call and provide the ID of the route table you want to delete in the following request parameters:
routeTableID
: For REST APIroute_table_id
: For gRPC API
To get the route table ID, use the list REST API method for the RouteTable resource or the RouteTableService/List gRPC API call and provide the folder ID in the following request parameters:
folderID
: For REST APIfolder_id
: For gRPC API