Overview
The VPC (Virtual Private Cloud) configuration provisions a complete network infrastructure for the production environment, including public and private subnets across multiple availability zones, NAT gateway for outbound connectivity, and proper tagging for EKS integration.Core Resources
VPC Module
The VPC is provisioned using the official AWS VPC Terraform module:Network Architecture
CIDR Block Design
Main VPC CIDR:10.0.0.0/16 (65,536 IP addresses)
Private Subnets (for EKS nodes and internal resources):
10.0.0.0/20- 4,096 IPs10.0.16.0/20- 4,096 IPs10.0.32.0/20- 4,096 IPs- Total: 12,288 private IPs
10.0.48.0/20- 4,096 IPs10.0.64.0/20- 4,096 IPs10.0.80.0/20- 4,096 IPs- Total: 12,288 public IPs
Availability Zones
Subnets are distributed across all available AWS availability zones in the region:VPC Features
NAT Gateway
Configuration:one_nat_gateway_per_az = true.
DNS Configuration
Hostname support:EKS Integration
Cluster Tags
The VPC and subnets are tagged for EKS cluster integration: VPC-level tag:Subnet Tags
Public subnets (for external load balancers):kubernetes.io/role/elb tag allows Kubernetes to automatically discover public subnets for creating internet-facing load balancers.
Private subnets (for internal load balancers):
kubernetes.io/role/internal-elb tag allows Kubernetes to automatically discover private subnets for creating internal load balancers.
Configuration Parameters
Name of the VPC
CIDR block for the VPC (65,536 IP addresses)
List of availability zones (auto-detected from region)
CIDR blocks for private subnets (3 subnets with 4,096 IPs each)
CIDR blocks for public subnets (3 subnets with 4,096 IPs each)
Enable NAT gateway for private subnet internet access
Use a single NAT gateway instead of one per AZ (cost optimization)
Enable DNS hostname support in the VPC
Auto-assign public IPs to instances in public subnets
Dependencies
This VPC module has no dependencies and is typically one of the first resources created. It provides networking infrastructure for:- EKS Module (
eks.tf): Uses private subnets for node groups - RDS Module (
rds.tf): Uses public subnets for database instances - Vault Module (
vault.tf): Uses public subnets for Vault instances and load balancers
Outputs
vpc_id: The VPC identifierprivate_subnets: List of private subnet IDspublic_subnets: List of public subnet IDsnat_gateway_ids: List of NAT gateway IDsvpc_cidr_block: The VPC CIDR block