#Title: site/routes.tf # Description: Route tables for subnets ####-- Routes --#### ##-- Public Subnet Routes --## # Public Route Table - Default Route to Internet Gateway resource "aws_route_table" "rt_public" { vpc_id = "${aws_vpc.myvpc.id}" route { cidr_block = "0.0.0.0/0" gateway_id = "${aws_internet_gateway.myigw.id}" } tags { Name = "rt_public" } } # Associate Subnet Public 01 with Route Table resource "aws_route_table_association" "rt_assoc_public01" { subnet_id = "${aws_subnet.subnet01-public.id}" route_table_id = "${aws_route_table.rt_public.id}" } # Associate Subnet Public 02 with Route Table resource "aws_route_table_association" "rt_assoc_public02" { subnet_id = "${aws_subnet.subnet02-public.id}" route_table_id = "${aws_route_table.rt_public.id}" } # Associate Subnet Public 03 with Route Table resource "aws_route_table_association" "rt_assoc_public03" { subnet_id = "${aws_subnet.subnet03-public.id}" route_table_id = "${aws_route_table.rt_public.id}" } ##-- Private Subnet Routes --## # Private Route Tables - Default Route to NAT GW in each AZ resource "aws_route_table" "rt_private01" { vpc_id = "${aws_vpc.myvpc.id}" route { cidr_block = "0.0.0.0/0" nat_gateway_id = "${aws_nat_gateway.nat_gw01.id}" } tags { Name = "rt_private01" } } resource "aws_route_table" "rt_private02" { vpc_id = "${aws_vpc.myvpc.id}" route { cidr_block = "0.0.0.0/0" nat_gateway_id = "${aws_nat_gateway.nat_gw02.id}" } tags { Name = "rt_private02" } } resource "aws_route_table" "rt_private03" { vpc_id = "${aws_vpc.myvpc.id}" route { cidr_block = "0.0.0.0/0" nat_gateway_id = "${aws_nat_gateway.nat_gw03.id}" } tags { Name = "rt_private03" } } # Associate Subnet Private 01 with Route Table resource "aws_route_table_association" "rt_assoc_private01" { subnet_id = "${aws_subnet.subnet01-private.id}" route_table_id = "${aws_route_table.rt_private01.id}" } # Associate Subnet Private 02 with Route Table resource "aws_route_table_association" "rt_assoc_private02" { subnet_id = "${aws_subnet.subnet02-private.id}" route_table_id = "${aws_route_table.rt_private02.id}" } # Associate Subnet Private 03 with Route Table resource "aws_route_table_association" "rt_assoc_private03" { subnet_id = "${aws_subnet.subnet03-private.id}" route_table_id = "${aws_route_table.rt_private03.id}" }