Overview and What You Will Learn
In this lab, you will create a custom-mode VPC with subnets in specific regions, compare it against the default auto-mode VPC's behavior, and understand exactly why GCP's global VPC model differs from the regional VPC model used elsewhere.
Why This Matters in Production
An engineer coming from AWS creates a new GCP project, expecting to define a VPC scoped to a single region the way they always have, then discovers the default auto-mode VPC has already created a subnet in every single region worldwide - dozens of subnets nobody asked for, in regions the workload will never touch, each representing unnecessary address space and potential surface area to account for during a security review.
Core Principles
A GCP VPC is a global resource by default - unlike an AWS VPC or Azure VNet, which are both scoped to a single region, a single GCP VPC can span every region, with individual subnets defined per-region inside it.
+------------------------------------------+| VPC: vpc-prod (global resource) || || +-------------------------------------+ || | Subnet: asia-south1 (10.0.1.0/24) | || +-------------------------------------+ || || +-------------------------------------+ || | Subnet: us-central1 (10.0.2.0/24) | || +-------------------------------------+ |+------------------------------------------+The default auto-mode VPC that GCP creates automatically for every new project pre-creates a subnet in every available region - convenient for quick experimentation, but rarely appropriate for a production environment where deliberate, minimal address space allocation matters.
Detailed Step-by-Step Practical Lab
- Create a project and examine its default auto-mode VPC:
gcloud projects create gcp-vpc-lab-2026 --name="VPC Design Lab"gcloud config set project gcp-vpc-lab-2026gcloud services enable compute.googleapis.com gcloud compute networks subnets list --network=default- Delete the default VPC's subnets and the VPC itself, to start from a deliberate, clean state:
gcloud compute networks subnets list --network=default --format="value(name,region)" | \ while read name region; do gcloud compute networks subnets delete "$name" --region="$region" --quiet done gcloud compute networks delete default --quiet- Create a custom-mode VPC, which starts with zero subnets until you explicitly create them:
gcloud compute networks create vpc-prod --subnet-mode=custom- Add only the specific subnets actually needed:
gcloud compute networks subnets create subnet-asia-south1 \ --network=vpc-prod \ --region=asia-south1 \ --range=10.0.1.0/24 gcloud compute networks subnets create subnet-us-central1 \ --network=vpc-prod \ --region=us-central1 \ --range=10.0.2.0/24- Confirm only these two deliberately created subnets exist, rather than one per region worldwide:
gcloud compute networks subnets list --network=vpc-prod- Expand a subnet's address range later if it grows too small - a supported, non-disruptive operation as long as the new range doesn't overlap another subnet:
gcloud compute networks subnets expand-ip-range subnet-asia-south1 \ --region=asia-south1 \ --prefix-length=23NoteExpanding a subnet's range (here, from a /24 to a larger /23) can only ever grow the range, never shrink it, and the new range must not overlap with any other subnet in the same VPC - plan initial subnet sizes with reasonable headroom to reduce how often this operation is needed.
- Clean up:
gcloud compute networks subnets delete subnet-asia-south1 --region=asia-south1 --quietgcloud compute networks subnets delete subnet-us-central1 --region=us-central1 --quietgcloud compute networks delete vpc-prod --quietgcloud projects delete gcp-vpc-lab-2026 --quietProduction Best Practices & Common Pitfalls
Common MistakeUsing the default auto-mode VPC in production, which creates a subnet in every global region automatically whether needed or not. This adds unnecessary complexity and potential exposure compared to a deliberately scoped custom-mode VPC with only the subnets actually needed for the workload.
TipPlan subnet CIDR ranges with real headroom from the start - a /24 subnet that turns out too small later can be expanded, but only if the expanded range doesn't collide with a neighboring subnet, which is easier to guarantee if ranges were planned generously to begin with.
- A VPC's global nature means resources in different regions within the same VPC can communicate using private IP addresses by default, without needing VPC peering or a VPN - this is a genuine architectural convenience specific to GCP's model.
- Subnet ranges must not overlap with each other within the same VPC, even across different regions - plan the full address allocation across all planned regions upfront, rather than assigning ranges to each region's subnet independently without checking for collisions.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
gcloud compute networks create --subnet-mode=custom |
Create a custom-mode VPC with no automatic subnets |
gcloud compute networks subnets create |
Add a subnet to a specific region within a VPC |
gcloud compute networks subnets list --network= |
List all subnets within a VPC |
gcloud compute networks subnets expand-ip-range |
Grow a subnet's address range |