VPC (Virtual Private Cloud)
Deploying and managing Google Virtual Private Cloud (VPC) for networking
Google Virtual Private Cloud (VPC) provides networking functionality for your Google Cloud resources and services. VPC offers global, scalable, and flexible networking for your Google Cloud workloads, enabling you to define your network topology with IP address ranges, subnets, routes, firewalls, and more.
Key Features
Global Resource: Single VPC can span multiple regions without requiring a VPN
Automatic Routing: Built-in routing for subnet-to-subnet traffic
Private Google Access: Access to Google services without public IPs
VPC Peering: Connect VPCs across projects without a gateway
Shared VPC: Share networks across multiple projects
VPC Network Peering: Connect VPC networks in different projects or organizations
Cloud NAT: Outbound connections for private instances
Hybrid Connectivity: Connect to on-premises networks via Cloud VPN or Cloud Interconnect
IPv4 and IPv6 Support: Dual-stack capabilities
Firewall Rules: Granular L3/L4 traffic control
VPC Flow Logs: Network monitoring and security analysis
Deploying VPC Networks with Terraform
Basic VPC with Custom Subnets
VPC with Secondary IP Ranges for GKE
VPC with Cloud NAT and Private Instances
Shared VPC Setup
VPC with Network Peering
Managing VPC with gcloud CLI
Creating Networks and Subnets
Working with Firewall Rules
Setting up Cloud NAT
Setting up VPC Peering
Managing Shared VPC
Real-World Example: Enterprise Hub-and-Spoke Network Architecture
This example showcases a complete enterprise network architecture with hub-and-spoke design:
Architecture Overview
Hub VPC for shared services and connectivity
Multiple spoke VPCs for application environments
VPC peering and custom routes
On-premises connectivity via VPN
Cloud NAT and Private Google Access
Hierarchical firewall policies
Terraform Implementation
Best Practices
Network Design
Use custom mode VPC and explicit subnet creation for better control
Choose non-overlapping CIDR ranges across your cloud and on-premises networks
Plan IP address allocation with future growth in mind
Use descriptive network and subnet names
Security
Implement a defense-in-depth approach with layered firewall rules
Use service accounts with minimum required permissions
Apply the principle of least privilege for firewall rules
Use Cloud Armor for edge protection when exposing services publicly
Enable VPC Flow Logs for network monitoring and forensics
Prefer IAP over public IP addresses for administration
Connectivity
Use VPC Peering for simple internal connectivity
Implement Cloud Router and NAT for egress from private instances
Choose appropriate hybrid connectivity options (VPN vs Interconnect)
Consider Network Connectivity Center for complex hybrid/multi-cloud setups
Test failover scenarios for critical network paths
Performance
Place resources in regions close to users
Use Global Load Balancing for worldwide deployments
Monitor network throughput and latency
Implement CDN for static content delivery
Optimize subnet sizes for anticipated workloads
Operations
Use infrastructure as code for all network configurations
Implement proper CIDR planning and documentation
Set up monitoring and alerts for network health
Create network diagrams and keep them updated
Develop runbooks for common network operations
Common Issues and Troubleshooting
Connectivity Issues
Check firewall rules for both ingress and egress traffic
Verify subnet routes and any custom routes
Check VPC peering status and configuration
Verify that service account has networking permissions
Check for overlapping CIDR ranges causing routing issues
VPC Peering Problems
Remember peering is non-transitive (A→B→C doesn't mean A→C)
Verify peering is established in both directions
Check for CIDR range overlaps between networks
Ensure both networks are in the same project or organization
Verify custom routes are being exported/imported if needed
Private Access and NAT Issues
Confirm Private Google Access is enabled on subnets
Check Cloud NAT configuration and allocation
Verify NAT logs for errors or rate limiting
Ensure instances don't have external IPs if using NAT
Check egress firewall rules that might block NAT traffic
VPN Connectivity Problems
Verify VPN gateways and tunnels are up
Check shared secret matches on both ends
Verify BGP session status if using dynamic routing
Validate firewall rules on both cloud and on-prem
Check for overlapping IP ranges causing routing conflicts
Further Reading
Last updated