# Title: site/nat_gateway.tf # Description: Create a NAT gateway for private subnets # Note: For true high availabity, you will want: # -An EIP and NAT GW per public subnet # -Route table per private subnet to route to NAT GW in same AZ # Create the required Elastic IPs to be assigned to the NAT Gateways resource "aws_eip" "eip_nat01" { vpc = true } resource "aws_eip" "eip_nat02" { vpc = true } resource "aws_eip" "eip_nat03" { vpc = true } # Create the NAT Gateways resource "aws_nat_gateway" "nat_gw01" { subnet_id = "${aws_subnet.subnet01-public.id}" allocation_id = "${aws_eip.eip_nat01.id}" tags { Name = "nat_gw01" } # Dependencies: Internet Gateway and EIP depends_on = ["aws_internet_gateway.myigw", "aws_eip.eip_nat01"] } resource "aws_nat_gateway" "nat_gw02" { subnet_id = "${aws_subnet.subnet02-public.id}" allocation_id = "${aws_eip.eip_nat02.id}" tags { Name = "nat_gw02" } # Dependencies: Internet Gateway and EIP depends_on = ["aws_internet_gateway.myigw", "aws_eip.eip_nat02"] } resource "aws_nat_gateway" "nat_gw03" { subnet_id = "${aws_subnet.subnet03-public.id}" allocation_id = "${aws_eip.eip_nat03.id}" tags { Name = "nat_gw03" } # Dependencies: Internet Gateway and EIP depends_on = ["aws_internet_gateway.myigw", "aws_eip.eip_nat03"] } # Route to the NAT Gateway provided elsewhere (in private route table)