For terraform there is an option "auto_create_network = false" to skip creation of a default net within a new project.
Is there also an option/flag for gcloud sdk / gcloud projects create (e.g. --skip-default-network
)? Or must we use org policy constraints/compute.skipDefaultNetworkCreation
(https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints)?
Terraform's solution is to delete the default network promptly after creation:
https://www.terraform.io/docs/providers/google/r/google_project.html#auto_create_network
Therefore, you:
gcloud compute networks delete
it after creation:Please test this in a sacrificial project to ensure it meets your needs
gcloud compute firewall-rules list \
--project=${PROJECT} \
--filter="network:/projects/${PROJECT}/global/networks/default" \
--format="value(name)" \
| xargs gcloud compute firewall-rules delete \
--project=${PROJECT} \
--quiet
gcloud compute networks delete default \
--project=${PROJECT} \
--quiet