When tried to delete GCP VPC following error occurs:
[email protected]:~ (<gcp-project>)$ gcloud compute networks delete cloud-sql The following networks will be deleted: - [cloud-sql] Do you want to continue (Y/n)? y ERROR: (gcloud.compute.networks.delete) Could not fetch resource: - The network resource 'projects/<gcp-project>/global/networks/cloud-sql' is already being used by 'projects/<gcp-project>/global/networkInstances/v-1171710760-6bcedd6c-b842-4dd0-9e64-65c2ef70f480'
Found out previously I had tried to enable App Engine access Cloud SQL privately by using Serverless VPC Connector
Then in App Engine app.yaml, following statement was used to tell App Engine to use the connector
vpc_access_connector: name: "projects/<gcp-project>/locations/us-central1/connectors/cloud-mysql"
This has resulting the App Engine to create a network interface with the VPC specified
Since you cannot purge App Engine, I have deployed another app that doesn’t require connection to the VPC:
git clone https://github.com/GoogleCloudPlatform/python-docs-samples cd python-docs-samples/appengine/standard_python3/building-an-app/building-an-app-1 gcloud app deploy
Now that the App Engine is no longer bind with the VPC
Make sure to delete the Serverless VPC connector
In App Engine, make sure to purge versions that uses the Serverless VPC connector.
Then try to delete the VPC again
gcloud compute networks delete cloud-sql The following networks will be deleted: - [cloud-sql] Do you want to continue (Y/n)? y Deleted [https://www.googleapis.com/compute/v1/projects/jye-01/global/networks/cloud-sql].