diff --git a/src/core/_modules/networking/nat_gateway.tf b/src/core/_modules/networking/nat_gateway.tf index aba950ada..12d9f5530 100644 --- a/src/core/_modules/networking/nat_gateway.tf +++ b/src/core/_modules/networking/nat_gateway.tf @@ -11,6 +11,19 @@ resource "azurerm_public_ip" "this_01" { tags = var.tags } +resource "azurerm_public_ip_prefix" "ng" { + count = var.ng_ippres_number + + name = format("%s-ippre-%02d", try(local.nonstandard[var.location_short].ng, "${var.project}-ng"), count.index + 1) + location = var.location + resource_group_name = var.resource_group_name + + prefix_length = 31 + zones = [count.index + 1] + + tags = var.tags +} + resource "azurerm_nat_gateway" "this" { count = var.ng_number @@ -29,3 +42,9 @@ resource "azurerm_nat_gateway_public_ip_association" "this_pip_01" { nat_gateway_id = azurerm_nat_gateway.this[0].id public_ip_address_id = azurerm_public_ip.this_01[count.index].id } + +resource "azurerm_nat_gateway_public_ip_prefix_association" "this_ippres" { + count = var.ng_ippres_number + nat_gateway_id = azurerm_nat_gateway.this[count.index].id + public_ip_prefix_id = azurerm_public_ip_prefix.ng[count.index].id +} diff --git a/src/core/_modules/networking/variables.tf b/src/core/_modules/networking/variables.tf index fb381edde..c8ce71e1d 100644 --- a/src/core/_modules/networking/variables.tf +++ b/src/core/_modules/networking/variables.tf @@ -44,3 +44,10 @@ variable "ng_number" { description = "Number of nat gateways to deploy" default = 1 } + + +variable "ng_ippres_number" { + type = number + description = "Number of Public IP Prefix assigned to the nat gateway" + default = 3 +} diff --git a/src/core/prod/italynorth.tf b/src/core/prod/italynorth.tf index e6a4a8e45..0d7db4d19 100644 --- a/src/core/prod/italynorth.tf +++ b/src/core/prod/italynorth.tf @@ -16,6 +16,9 @@ module "networking_itn" { vnet_cidr_block = "10.20.0.0/16" pep_snet_cidr = ["10.20.2.0/23"] + ng_number = 3 + ng_ips_number = 0 + tags = local.tags } diff --git a/src/core/prod/westeurope.tf b/src/core/prod/westeurope.tf index 20a531fd2..012046623 100644 --- a/src/core/prod/westeurope.tf +++ b/src/core/prod/westeurope.tf @@ -13,7 +13,8 @@ module "networking_weu" { vnet_cidr_block = "10.0.0.0/16" pep_snet_cidr = ["10.0.240.0/23"] - ng_ips_number = 2 + ng_ips_number = 2 + ng_ippres_number = 0 tags = merge(local.tags, { Source = "https://github.com/pagopa/io-infra" }) }