1

I want to delete a GCP vpc, I get:

Failed to delete the network. Error: Some of the resources are referenced by other existing resources and cannot be deleted.

How do I determine what these other existing resources are?

schoon
  • 2,858
  • 3
  • 46
  • 78

2 Answers2

4

The resources that can be using a VPC network are the following:

  • Subnets
  • Static Internal IP addresses
  • Firewall rules
  • Routes (including static and routes created automatically/dynamically)
  • VPC network Peering
  • Private Service connection
  • Instances

the only way is to check each category manually and make sure that are not using the VPC.

For more information regarding each kind of resource, visit this documentation [1].

Cheers!


[1] https://cloud.google.com/vpc/docs/vpc#specifications

BraveAdmin
  • 685
  • 1
  • 6
  • 15
0

There are a lot of resources that relate directly to a VPC NW in GCP.

Two options of listing them:

  1. You can list them directly with the API
  2. You can use this python script to list most of them. My guess is you'll find the resource that blocks you from deleting the NW here. The output looks like this:

--------------------------------------------
Subnetworks in Network alon-test-network:
--------------------------------------------
https://www.googleapis.com/compute/v1/projects/alon-lavian/regions/us-central1/subnetworks/alon-test-network
https://www.googleapis.com/compute/v1/projects/alon-lavian/regions/asia-east1/subnetworks/subnet-2

--------------------------------------------
Instances in VPC alon-test-network:
--------------------------------------------
instance-3, zone: us-central1-a

--------------------------------------------
FW rules in Network alon-test-network:
--------------------------------------------
alon-test-network-allow-custom
alon-test-network-allow-http
alon-test-network-allow-https
alon-test-network-allow-icmp
default-allow-ssh-alon

--------------------------------------------
Routes in Network alon-test-network:
--------------------------------------------
default-route-d957345c6aef02c8 destination range: 10.128.0.0/20
default-route-dcecf66e898091c4 destination range: 10.0.0.0/9
default-route-fa59cdb8270a46ab destination range: 0.0.0.0/0

--------------------------------------------
VPN GW in Network alon-test-network:
--------------------------------------------
alon-vpn

--------------------------------------------
Routers in Network alon-test-network:
--------------------------------------------

--------------------------------------------
Addresses in Network alon-test-network:
--------------------------------------------
alon-address ,users: ['https://www.googleapis.com/compute/v1/projects/alon-lavian/zones/us-central1-a/instances/instance-3']
Alon Lavian
  • 1,149
  • 13
  • 14