File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 5
5
length (var. database_subnets ),
6
6
length (var. redshift_subnets ),
7
7
)
8
- nat_gateway_count = var. single_nat_gateway ? 1 : var. one_nat_gateway_per_az ? length (var. azs ) : local. max_subnet_length
8
+ nat_gateway_count = var. single_nat_gateway ? 1 : var. one_nat_gateway_per_az ? length (var. azs ) : local. max_subnet_length < length (var . public_subnets ) ? local . max_subnet_length : length (var . public_subnets )
9
9
10
10
# Use `local.vpc_id` to give a hint to Terraform that subnets should be deleted before secondary CIDR blocks can be free!
11
11
vpc_id = element (
@@ -200,7 +200,7 @@ resource "aws_route" "public_internet_gateway_ipv6" {
200
200
# There are as many routing tables as the number of NAT gateways
201
201
# ################
202
202
resource "aws_route_table" "private" {
203
- count = var. create_vpc && local . max_subnet_length > 0 ? local . nat_gateway_count : 0
203
+ count = var. create_vpc && length (var . private_subnets ) > 0 ? var . single_nat_gateway ? 1 : length (var . private_subnets ) : 0
204
204
205
205
vpc_id = local. vpc_id
206
206
@@ -956,7 +956,7 @@ resource "aws_nat_gateway" "this" {
956
956
}
957
957
958
958
resource "aws_route" "private_nat_gateway" {
959
- count = var. create_vpc && var. enable_nat_gateway ? local . nat_gateway_count : 0
959
+ count = var. create_vpc && var. enable_nat_gateway ? var . single_nat_gateway ? 1 : length (var . private_subnets ) : 0
960
960
961
961
route_table_id = element (aws_route_table. private . * . id , count. index )
962
962
destination_cidr_block = " 0.0.0.0/0"
You can’t perform that action at this time.
0 commit comments