Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Virtual Private Cloud
  • Getting started
    • All guides
      • Creating a static route
      • Creating and setting up a NAT gateway
      • Getting information about a NAT gateway
      • Moving a route table between folders
      • Getting information about a route table
      • Moving a NAT gateway between folders
      • Deleting a route table
      • Deleting a NAT gateway
    • Enabling a software-accelerated network
    • Chart of network connections
    • Viewing operations with resources
  • DDoS Protection
  • Access management
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ

In this article:

  • Disassociating a NAT gateway from a route table
  • Deleting a NAT gateway
  1. Step-by-step guides
  2. Static routing
  3. Deleting a NAT gateway

Deleting a NAT gateway

Written by
Yandex Cloud
Updated at May 5, 2025
  • Disassociating a NAT gateway from a route table
  • Deleting a NAT gateway

If you no longer need the NAT gateway, you can delete it. Before deleting your NAT gateway, disassociate it from all route tables that use it.

Disassociating a NAT gateway from a route tableDisassociating a NAT gateway from a route table

Management console
CLI
Terraform
API
  1. In the management console, go to the folder where you need to disassociate a NAT gateway.
  2. In the list of services, select Virtual Private Cloud.
  3. In the left-hand panel, select Routing tables.
  4. In the list that opens, find the route table with the NAT gateway listed in its Static routes column.
  5. In the table row, click and select Edit.
  6. In the window that opens, click in the row with the NAT gateway name.
  7. Click Save.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To disassociate a NAT gateway from a route table:

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

    yc vpc route-table update --help
    
  2. Get the name or ID of the route table the NAT gateway is associated with:

    yc vpc route-table list
    

    Result:

    +----------------------+----------------------+-------------+----------------------+
    |          ID          |         NAME         | DESCRIPTION |      NETWORK-ID      |
    +----------------------+----------------------+-------------+----------------------+
    | enpcaaqahk3c******** | test-table           |             | enptgj64mv2r******** |
    +----------------------+----------------------+-------------+----------------------+
    
    
  3. Disassociate the NAT gateway:

    yc vpc route-table update <route_table_name_or_ID> --clear-routes
    

    Use either the --id or --name parameter.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

With Terraform, 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. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

To disassociate a NAT gateway from a route table created using Terraform:

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

    Example of a table description in the Terraform configuration
    ...
    resource "yandex_vpc_route_table" "routetable" {
      folder_id  = "<user_folder_ID>"
      name       = "<route_table_name>"
      network_id = "<network_ID>"
      static_route {
        destination_prefix = "0.0.0.0/0"
        gateway_id         = <gateway_ID>
      }
    }
    ...
    
  2. Delete the static_route object.

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

  4. Check the configuration using this command:

    terraform validate
    

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

    Success! The configuration is valid.
    
  5. Run this command:

    terraform plan
    

    The terminal will display a list of resources with their parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

  6. Apply the configuration changes:

    terraform apply
    
  7. Confirm the changes: type yes into the terminal and press Enter.

    You can check the updates using the management console or this CLI command:

    yc vpc route-table get <route_table_name_or_ID>
    

    Use either the --id or --name parameter.

To disassociate a NAT gateway from a route table, delete the static route with that NAT gateway from the route table. To do this, use the update REST API method for the RouteTable resource or the RouteTableService/Update gRPC API call. In your request, provide a list of static routes without the route you want to delete under:

  • staticRoutes: For REST API
  • static_routes: For gRPC API

If the list contained a single static route, provide an empty list.

To get a list of static routes, use the get REST API method for the RouteTable resource or the RouteTableService/Get gRPC API call. In your request, provide the route table ID in this parameter:

  • routeTableId: For REST API
  • route_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 NAT gatewayDeleting a NAT gateway

Warning

Before deleting a NAT gateway, disassociate it from all route tables it is associated with.

Management console
CLI
Terraform
API

To delete a NAT gateway:

  1. In the management console, go to the folder where you need to delete a NAT gateway.
  2. In the list of services, select Virtual Private Cloud.
  3. In the left-hand panel, select Gateways.
  4. Click in the row with the NAT gateway name and select Delete.
  5. In the window that opens, click Delete.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To delete a route table:

  1. View the description of the CLI command for deleting a NAT gateway:

    yc vpc gateway delete --help
    
  2. Get the name or ID of the NAT gateway to delete:

    yc vpc gateway list
    

    Result:

    +----------------------+-----------+-------------+
    |          ID          |   NAME    | DESCRIPTION |
    +----------------------+-----------+-------------+
    | enpkq171u4gb******** | gateway-1 |             |
    +----------------------+-----------+-------------+
    
  3. Delete the NAT gateway:

    yc vpc gateway delete <gateway_name_or_ID>
    

    Use either the --id or --name parameter.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

With Terraform, 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. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

To delete a NAT gateway created using Terraform:

  1. Open the Terraform configuration file and delete the NAT gateway description fragment.

    Example of a NAT gateway description in the Terraform configuration
    ...
    resource "yandex_vpc_gateway" "natgateway" {
      folder_id      = "<folder_ID>"
      name = "<gateway_name>"
      shared_egress_gateway {}
    }
    ...
    
  2. In the command line, go to the directory with the Terraform configuration file.

  3. Check the configuration using this command:

    terraform validate
    

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

    Success! The configuration is valid.
    
  4. Run this command:

    terraform plan
    

    The terminal will display a list of resources with their parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

  5. Apply the configuration changes:

    terraform apply
    
  6. Confirm the changes: type yes into the terminal and press Enter.

    You can check the updates using the management console or this CLI command:

    yc vpc gateway list
    

To delete a NAT gateway, use the delete REST API method for the Gateway resource or the GatewayService/Delete gRPC API call. In your request, provide the ID of the NAT gateway you want to delete in this parameter:

  • gatewayId: For REST API
  • gateway_id: For gRPC API

To get the NAT gateway ID, use the list REST API method for the Gateway resource or the GatewayService/List gRPC API call. In your request, provide the folder ID in this parameter:

  • folderId: For REST API
  • folder_id: For gRPC API

Was the article helpful?

Previous
Deleting a route table
Next
Creating a service connection
Yandex project
© 2025 Yandex.Cloud LLC