Commit 712e1f97 authored by Yauheni Batsianouski's avatar Yauheni Batsianouski Committed by GitHub

fix: Create only required number of NAT gateways (#492)

parent 30df090a
......@@ -9,14 +9,15 @@ module "vpc" {
cidr = "10.0.0.0/16"
azs = ["eu-west-1a", "eu-west-1b", "euw1-az3"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_ipv6 = true
azs = ["eu-west-1a", "eu-west-1b", "euw1-az3"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
database_subnets = ["10.0.5.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24", "10.0.104.0/24"]
enable_nat_gateway = true
single_nat_gateway = true
# single_nat_gateway = true
create_database_subnet_group = false
public_subnet_tags = {
Name = "overridden-name-public"
......
......@@ -5,7 +5,7 @@ locals {
length(var.database_subnets),
length(var.redshift_subnets),
)
nat_gateway_count = var.single_nat_gateway ? 1 : var.one_nat_gateway_per_az ? length(var.azs) : local.max_subnet_length
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)
# Use `local.vpc_id` to give a hint to Terraform that subnets should be deleted before secondary CIDR blocks can be free!
vpc_id = element(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment