# Minimal self-contained VPC with one public subnet — enough for a single public # instance, and a clean base to extend (private subnets, RDS, ALB) when scaling up. resource "aws_vpc" "this" { cidr_block = "10.0.0.0/16" enable_dns_support = true enable_dns_hostnames = true tags = merge(local.tags, { Name = "${var.project_name}-vpc" }) } resource "aws_internet_gateway" "this" { vpc_id = aws_vpc.this.id tags = merge(local.tags, { Name = "${var.project_name}-igw" }) } resource "aws_subnet" "public" { vpc_id = aws_vpc.this.id cidr_block = "10.0.1.0/24" availability_zone = data.aws_availability_zones.available.names[0] map_public_ip_on_launch = true tags = merge(local.tags, { Name = "${var.project_name}-public" }) } resource "aws_route_table" "public" { vpc_id = aws_vpc.this.id route { cidr_block = "0.0.0.0/0" gateway_id = aws_internet_gateway.this.id } tags = merge(local.tags, { Name = "${var.project_name}-public-rt" }) } resource "aws_route_table_association" "public" { subnet_id = aws_subnet.public.id route_table_id = aws_route_table.public.id }