diff --git a/main.tf b/main.tf index b9ec582..7229dba 100644 --- a/main.tf +++ b/main.tf @@ -26,13 +26,13 @@ resource "aws_route" "private_nat_gateway" { route_table_id = "${element(aws_route_table.private.*.id, count.index)}" destination_cidr_block = "0.0.0.0/0" nat_gateway_id = "${element(aws_nat_gateway.natgw.*.id, count.index)}" - count = "${length(var.private_subnets) * lookup(map(var.enable_nat_gateway, 1), "true", 0)}" + count = "${length(var.azs) * lookup(map(var.enable_nat_gateway, 1), "true", 0)}" } resource "aws_route_table" "private" { vpc_id = "${aws_vpc.mod.id}" propagating_vgws = ["${var.private_propagating_vgws}"] - count = "${length(var.private_subnets)}" + count = "${length(var.azs)}" tags = "${merge(var.tags, map("Name", format("%s-rt-private-%s", var.name, element(var.azs, count.index))))}" } @@ -87,13 +87,13 @@ resource "aws_subnet" "public" { resource "aws_eip" "nateip" { vpc = true - count = "${length(var.private_subnets) * lookup(map(var.enable_nat_gateway, 1), "true", 0)}" + count = "${length(var.azs) * lookup(map(var.enable_nat_gateway, 1), "true", 0)}" } resource "aws_nat_gateway" "natgw" { allocation_id = "${element(aws_eip.nateip.*.id, count.index)}" subnet_id = "${element(aws_subnet.public.*.id, count.index)}" - count = "${length(var.private_subnets) * lookup(map(var.enable_nat_gateway, 1), "true", 0)}" + count = "${length(var.azs) * lookup(map(var.enable_nat_gateway, 1), "true", 0)}" depends_on = ["aws_internet_gateway.mod"] }