04-Route Tables & Peering

Module creating Route Tables and VPC Peering with Build VPC

Stage Modulemodules/04-route-tables-peering

Purpose

Creates route tables for subnets and sets up VPC Peering with Build VPC to enable communication between the 2 VPCs.

Created Resources

ResourceDescription
aws_route_table.mainRoute table for main subnet
aws_route_table.secondRoute table for second subnet
aws_route.internet_mainRoute 0.0.0.0/0 → IGW (main)
aws_route.internet_secondRoute 0.0.0.0/0 → IGW (second)
aws_vpc_peering_connection.buildVPC Peering with Build VPC (optional)
aws_route.to_buildRoute to Build VPC via peering

VPC Peering

VPC Peering is only created when peer_build_vpc_id is not empty:

VPC Peering Configuration
# terraform.tfvars
peer_build_vpc_id   = "vpc-xxxxxxxxx"      # VPC ID to peer with
peer_build_vpc_cidr = "172.31.0.0/16"      # CIDR of peer VPC
peer_region         = ""                    # Empty = same region

# Leave peer_build_vpc_id empty to disable peering
peer_build_vpc_id = ""

Info

When VPC Peering is enabled, preflight-check.ps1 (Check 7b) will automatically scan the Build VPC route table to suggest a non-conflicting stage_index.

Route Table Rules

Route TableDestinationTarget
milu2stage-main-rtSTAGE_VPC_CIDRlocal
milu2stage-main-rt0.0.0.0/0Internet Gateway
milu2stage-main-rtPEER_BUILD_VPC_CIDRVPC Peering
milu2stage-second-rtSTAGE_VPC_CIDRlocal
milu2stage-second-rt0.0.0.0/0Internet Gateway