In this guide, weβll explore how to create and use Auto-mode and Custom-mode VPC networks in Google Cloud. Weβll also launch a VM instance in a custom subnet and verify.
β Step-01: Introduction
We will perform the following steps:
- Create Auto Mode VPC Network
- Create Custom VPC Network
- Create Subnet in Custom VPC Network
- Launch a VM instance inside the custom subnet with a webserver startup script
- Verify deployment
- Clean-Up resources
β Step-02: Understand Default VPC Network
- Navigate to VPC Network β default.
- Notice that default subnets are pre-created and ready to use in all regions.
β Step-03: Auto Mode VPC Network
Step-03-01: Create Auto Mode VPC
- Go to VPC Network β CREATE VPC NETWORK
- Name: vpc1-auto
- Description: Automode VPC
- Subnets: Automatic
- Firewall Rules:
allow-custom (internal access)
allow-icmp
allow-rdp
allow-ssh
- Dynamic Routing Mode: Regional (default)
- Click CREATE
Step-03-02: Verify Auto Mode VPC
- Go to vpc1-auto β Subnets
- Verify that subnets are automatically created in each region.
β Step-04: Custom Mode VPC Network
Step-04-01: Create Custom Mode VPC
- Go to VPC Network β CREATE VPC NETWORK
- Name: vpc2-custom
- Description: Custom-mode-VPC
- Subnets: Custom
- Firewall Rules:
allow-ssh
allow-icmp
- Dynamic Routing Mode: Regional (default)
- Click CREATE
Step-04-02: Create a Subnet
Go to VPC Networks β vpc2-custom β Subnets β ADD SUBNET
- Name: mysubnet1
- Region: us-central1
- IP Stack: IPv4
- Subnet Range: 10.225.0.0/20
- Leave others default β Click ADD
β Step-05: Create VM Instance in Custom Subnet
Using gcloud CLI:
# Set Project
gcloud config set project PROJECT_ID
gcloud config set project gcp-zero-to-hero-468909
# Create VM in mysubnet1
gcloud compute instances create myvm1 \
--zone=us-central1-a \
--machine-type=e2-micro \
--network-interface=subnet=mysubnet1
# List Compute Instances (Optional)
gcloud compute instances list
# Describe Network Details (Optional)
gcloud compute instances describe myvm1 --zone=us-central1-a
# Connect to VM (Optional)
gcloud compute ssh --zone "us-central1-a" "myvm1" --project "gcp-zero-to-hero-468909"
β Step-06: Verify Deployment
- Confirm that VM is deployed inside vpc2-custom β mysubnet1.
- Check the internal IP address.
- If you added a startup script with webserver installation (Apache/Nginx), open the external IP in browser to verify.
β Step-07: Clean-Up
# List Instances
gcloud compute instances list
# Delete VM
gcloud compute instances delete myvm1 \
--zone=us-central1-a \
--delete-disks=all
π Summary
- Auto-mode VPC = Google creates subnets in all regions automatically.
- Custom-mode VPC = You create your own subnets with full control.
- Always use Custom mode VPC for real workloads.
Top comments (0)