From 40b35ccf7dc2b7f1a9c4e96471ebca4a098e3704 Mon Sep 17 00:00:00 2001 From: Novikov Sergey Date: Fri, 26 Jan 2024 17:01:45 +0100 Subject: [PATCH] Pass parameter for NAT to VPC sub-module (#26) --- README.md | 8 ++++++++ main.tf | 7 ++++--- variables.tf | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2dcecfe..64c986f 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,14 @@ Type: `bool` Default: `true` +### [vpc\_one\_nat\_gateway\_per\_az](#input\_vpc\_one\_nat\_gateway\_per\_az) + +Description: Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs` + +Type: `bool` + +Default: `true` + ### [vpc\_reuse\_nat\_ips](#input\_vpc\_reuse\_nat\_ips) Description: Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external\_nat\_ip\_ids' variable diff --git a/main.tf b/main.tf index 23179a3..4b66b58 100644 --- a/main.tf +++ b/main.tf @@ -2,7 +2,7 @@ # VPC Resources # ------------------------------------------------------------------------------------------------- module "aws_vpc" { - source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v5.4.0" + source = "github.com/terraform-aws-modules/terraform-aws-vpc?ref=v5.5.1" cidr = var.vpc_cidr azs = var.vpc_subnet_azs @@ -18,8 +18,9 @@ module "aws_vpc" { enable_dns_hostnames = var.vpc_enable_dns_hostnames enable_dns_support = var.vpc_enable_dns_support - reuse_nat_ips = var.vpc_reuse_nat_ips - external_nat_ip_ids = local.ids_of_eips_for_natgws + one_nat_gateway_per_az = var.vpc_one_nat_gateway_per_az + reuse_nat_ips = var.vpc_reuse_nat_ips + external_nat_ip_ids = local.ids_of_eips_for_natgws customer_gateways = var.vpc_customer_gateways diff --git a/variables.tf b/variables.tf index ad66edc..7393e2e 100644 --- a/variables.tf +++ b/variables.tf @@ -35,6 +35,12 @@ variable "vpc_enable_nat_gateway" { default = true } +variable "vpc_one_nat_gateway_per_az" { + description = "Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs`" + type = bool + default = true +} + variable "vpc_reuse_nat_ips" { description = "Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external_nat_ip_ids' variable" type = bool