[Yandex Cloud documentation](../../index.md) > [Yandex Virtual Private Cloud](../index.md) > [Step-by-step guides](index.md) > Static routing > Deleting a route table

# Deleting a route table

If you no longer need the [route table](../concepts/routing.md), you can [delete](#delete-route-table) it. Before deleting a table, [disassociate it](#unlink-route-table) from all subnets it is associated with.

## Disassociating a route table from a subnet {#unlink-route-table}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder containing the route table you want to dissociate.
  1. Navigate to **Virtual Private Cloud**.
  1. Go to the cloud network the route table belongs to.

     {% note info %}

     If you do not know which network the route table belongs to, in the left-hand panel, select ![image](../../_assets/console-icons/route.svg) **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.

     {% endnote %}

  1. In the list of subnets, find the subnet associated with the route table.
  1. Disassociate the route table from the subnet using any of these methods:
     * In the row with subnet information, click ![image](../../_assets/console-icons/xmark.svg) next to the route table name.
     * In the row with subnet information, click ![image](../../_assets/console-icons/ellipsis.svg) and select **Edit**. In the window that opens, click ![image](../../_assets/console-icons/xmark.svg) in the row with the route table name and save the changes.
     * Open the subnet information and click ![image](../../_assets/console-icons/xmark.svg) next to the route table name.
     * Open the subnet information and click **Edit** in the top-right corner. In the window that opens, click ![image](../../_assets/console-icons/xmark.svg) in the row with the route table name and save the changes.

- 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 disassociate a route table from a subnet:

  1. View the description of the CLI command for updating subnet parameters:

      ```bash
      yc vpc subnet update --help
      ```

  1. Get the name or ID of the subnet the route table is associated with:

      ```bash
      yc vpc subnet list
      ```
      Result:
      ```text
      +----------------------+----------------------------+----------------------+----------------------+---------------+-----------------+
      |          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] |
      +----------------------+----------------------------+----------------------+----------------------+---------------+-----------------+

      ```
  1. Disassociate the route table from the subnet:
      ```bash
      yc vpc subnet update <subnet_name_or_ID> --disassociate-route-table
      ```
      Use either the `--id` or `--name` parameter.

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../terraform/authentication.md) using the appropriate method.

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the guides on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../terraform/index.md).

  To disassociate a route table from a subnet in the infrastructure created in Terraform:

  1. Open the Terraform configuration file and find the fragment with the description of the subnet associated with the route table:

     {% cut "Example of a subnet description in the Terraform configuration" %}

     ```hcl
     ...
     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>"
     }
     ...
     ```

     {% endcut %}

  1. Delete the route table description string from this fragment:

     ```hcl
     route_table_id = "<route_table_ID>"
     ```

  1. In the command line, go to the directory with the Terraform configuration file.

  1. Check the configuration using this command:

     ```bash
     terraform validate
     ```

     If the configuration is valid, you will get this message:

     ```text
     Success! The configuration is valid.
     ```

  1. Run this command:

     ```bash
     terraform plan
     ```

     You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.

  1. Apply the configuration changes:

     ```bash
     terraform apply
     ```

  1. Type `yes` and press **Enter** to confirm changes.

     You can check the updates using the [management console](https://console.yandex.cloud) or this [CLI](../../cli/quickstart.md) command:

     ```bash
     yc vpc subnet get <subnet_name_or_ID>
     ```
     Use either the `--id` or `--name` parameter.

- API {#api}

  To disassociate a route table from a subnet, use the [update](../api-ref/Subnet/update.md) REST API method for the [Subnet](../api-ref/Subnet/index.md) resource or the [SubnetService/Update](../api-ref/grpc/Subnet/update.md) gRPC API call, and provide an empty string in the following request parameter:
    * `routeTableId`: For REST API
    * `route_table_id`: For gRPC API

  {% note 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.
  
  {% endnote %}

{% endlist %}

## Deleting a route table {#delete-route-table}

{% note warning %}

Before deleting a table, [disassociate it](#unlink-route-table) from all subnets it is associated with.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

  To delete a route table:
  1. In the [management console](https://console.yandex.cloud), select the folder containing the route table you want to delete.
  1. Navigate to **Virtual Private Cloud**.
  1. In the left-hand panel, select ![image](../../_assets/console-icons/route.svg) **Routing tables**.
  1. Click ![image](../../_assets/console-icons/ellipsis.svg) in the row with the table name and select **Delete**.
  1. In the window that opens, click **Delete**.

- 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 delete a route table:

  1. View the description of the CLI command for deleting a route table:

      ```bash
      yc vpc route-table delete --help
      ```

  1. Get the name or ID of the route table to delete:

      ```bash
      yc vpc route-table list
      ```
      Result:
      ```text
      +----------------------+---------+-------------+----------------------+
      |          ID          |  NAME   | DESCRIPTION |      NETWORK-ID      |
      +----------------------+---------+-------------+----------------------+
      | enpd3s8svtkd******** | table-1 |             | enptgj64mv2r******** |
      +----------------------+---------+-------------+----------------------+
      ```
  1. Delete the route table:
      ```bash
      yc vpc route-table delete <route_table_name_or_ID>
      ```
      Use either the `--id` or `--name` parameter.

- Terraform {#tf}

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../terraform/authentication.md) using the appropriate method.

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the guides on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../terraform/index.md).

  To delete a route table created using Terraform:

  1. Open the Terraform configuration file and delete the route table description fragment.

     {% cut "Example of a route table description in the Terraform configuration" %}

     ```hcl
     ...
     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"
       }
     }
     ...
     ```

     {% endcut %}

  1. In the command line, navigate to the directory with the Terraform configuration file.

  1. Check the configuration using this command:

     ```bash
     terraform validate
     ```

     If the configuration is valid, you will get this message:

     ```text
     Success! The configuration is valid.
     ```

  1. Run this command:

     ```bash
     terraform plan
     ```

     You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.

  1. Apply the configuration changes:

     ```bash
     terraform apply
     ```

  1. Type `yes` and press **Enter** to confirm changes.

     You can check the updates using the [management console](https://console.yandex.cloud) or this [CLI](../../cli/quickstart.md) command:

     ```bash
     yc vpc subnet list
     ```

- API {#api}

  To delete a route table, use the [delete](../api-ref/RouteTable/delete.md) REST API method for the [RouteTable](../api-ref/RouteTable/index.md) resource or the [RouteTableService/Delete](../api-ref/grpc/RouteTable/delete.md) gRPC API call, and provide the ID of the route table you want to delete in the following request parameter:
    * `routeTableID`: For REST API
    * `route_table_id`: For gRPC API

  To get the route table ID, use the [list](../api-ref/RouteTable/list.md) REST API method for the [RouteTable](../api-ref/RouteTable/index.md) resource or the [RouteTableService/List](../api-ref/grpc/RouteTable/list.md) gRPC API call, and provide the folder ID in the following request parameter:
    * `folderID`: For REST API
    * `folder_id`: For gRPC API

{% endlist %}