List and delete Cloud Routers
This document describes the following tasks for managing Cloud Router:
- Listing the Cloud Routers in your project
- Deleting the Cloud Routers that you don't use
Before you begin
gcloud
If you want to use the command-line examples in this guide, do the following:
- Install or update to the latest version of the Google Cloud CLI.
- Set a default region and zone.
API
If you want to use the API examples in this guide, set up API access.
List Cloud Routers
To list all the Cloud Routers in a project, follow these steps.
Console
In the Google Cloud console, go to the Cloud Routers page.
On the Cloud Routers page, view a list of your Cloud Routers.
gcloud
Run the list
command. To restrict the list to only one region, specify
--filter="region:(<var>REGION</var>)
.
gcloud compute routers list \ --project=PROJECT_ID \ [--filter="region:(REGION)]
Replace the following:
PROJECT_ID
: the ID of the project for which you want to list Cloud RoutersREGION
: the region for which you want to list routers—for example,asia-east1
The output is similar to the following:
NAME REGION NETWORK my-router asia-east1 my-network
API
Use the
routers.aggregatedList
method:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/aggregated/routers
Replace PROJECT_ID
with the ID of the project for which you
want to list Cloud Routers.
To list only the Cloud Routers in a specific region, use the
routers.list
method:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers
Replace the following:
PROJECT_ID
: the ID of the project for which you want to list Cloud RoutersREGION
: the region for which you want to list Cloud Routers
Delete Cloud Routers
Before you delete a Cloud Router, check that it's not being used by another resource, such as a Cloud VPN tunnel or a VLAN attachment. You must delete the associated resource before you can delete the Cloud Router. However, you're not required to remove BGP sessions before you delete the Cloud Router.
To delete the Cloud Router, follow these steps.
Console
In the Google Cloud console, go to the Cloud Routers page.
Select the checkbox next to the Cloud Router that you want to delete.
Click
Delete.
gcloud
Run the delete
command. Specify the name and location of the
Cloud Router that you want to delete.
gcloud compute routers delete ROUTER_NAME \ --project=PROJECT_ID \ --region=asia-east1
The output is similar to the following:
Deleted [https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/asia-east1/routers/ROUTER_NAME].
API
Use the
routers.delete
method:
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/routers/ROUTER_NAME
Replace the following:
PROJECT_ID
: the project that contains the Cloud Router that you want to deleteREGION
: the region where the Cloud Router is locatedROUTER_NAME
: the name of the Cloud Router
What's next
- To view the configuration of a Cloud Router, its BGP sessions, and the routes that Cloud Router is advertising, see View router details.
- To troubleshoot issues when using Cloud Router, see Troubleshooting.