Skip to content

Commit

Permalink
Merge branch 'main' into EC-357-migrazione-risorse-nei-moduli-di-core…
Browse files Browse the repository at this point in the history
…-prod-ai-2
  • Loading branch information
Krusty93 authored Sep 4, 2024
2 parents 58aadd3 + f285f2f commit 8369a13
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/core/_modules/networking/nat_gateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
}
7 changes: 7 additions & 0 deletions src/core/_modules/networking/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions src/core/prod/italynorth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/prod/westeurope.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
}
Expand Down

0 comments on commit 8369a13

Please sign in to comment.