Skip to content

Commit

Permalink
feat: fix reachability from appbel3 to downstream applications (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-calabrese authored Oct 4, 2024
1 parent 2e86ae8 commit 1dc1e98
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 7 deletions.
17 changes: 17 additions & 0 deletions src/domains/cgn/_modules/functions_apps/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ data "azurerm_subnet" "snet_backendl2" {
resource_group_name = local.resource_group_name_common
}

data "azurerm_subnet" "snet_backendl3" {
name = "appbackendl3"
virtual_network_name = local.vnet_name_common
resource_group_name = local.resource_group_name_common
}

data "azurerm_subnet" "snet_backendli" {
name = "appbackendli"
virtual_network_name = local.vnet_name_common
Expand Down Expand Up @@ -82,3 +88,14 @@ data "azurerm_monitor_action_group" "error_action_group" {
name = "${replace("${var.project}", "-", "")}error"
resource_group_name = local.resource_group_name_common
}

data "azurerm_subnet" "private_endpoints_subnet" {
name = "pendpoints"
virtual_network_name = local.vnet_name_common
resource_group_name = local.resource_group_name_common
}

data "azurerm_private_dns_zone" "function_app" {
name = "privatelink.azurewebsites.net"
resource_group_name = local.resource_group_name_common
}
44 changes: 44 additions & 0 deletions src/domains/cgn/_modules/functions_apps/function_app_cgn.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module "function_cgn" {
data.azurerm_subnet.snet_backendl2.id,
data.azurerm_subnet.snet_backendli.id,
data.azurerm_subnet.snet_apim_v2.id,
data.azurerm_subnet.snet_backendl3.id
]

sticky_app_setting_names = [
Expand Down Expand Up @@ -91,7 +92,50 @@ module "function_cgn_staging_slot" {
data.azurerm_subnet.snet_backendl2.id,
data.azurerm_subnet.snet_backendli.id,
data.azurerm_subnet.snet_apim_v2.id,
data.azurerm_subnet.snet_backendl3.id,
]

tags = var.tags
}

resource "azurerm_private_endpoint" "function_sites" {
name = "${var.project}-cgn-fn-pep"
location = var.location
resource_group_name = var.resource_group_name
subnet_id = data.azurerm_subnet.private_endpoints_subnet.id

private_service_connection {
name = "${var.project}-cgn-fn-pep"
private_connection_resource_id = module.function_cgn.id
is_manual_connection = false
subresource_names = ["sites"]
}

private_dns_zone_group {
name = "private-dns-zone-group"
private_dns_zone_ids = [data.azurerm_private_dns_zone.function_app.id]
}

tags = var.tags
}

resource "azurerm_private_endpoint" "staging_function_sites" {
name = "${var.project}-cgn-fn-staging-pep"
location = var.location
resource_group_name = var.resource_group_name
subnet_id = data.azurerm_subnet.private_endpoints_subnet.id

private_service_connection {
name = "${var.project}-cgn-fn-pep"
private_connection_resource_id = module.function_cgn.id
is_manual_connection = false
subresource_names = ["sites-${module.function_cgn_staging_slot.name}"]
}

private_dns_zone_group {
name = "private-dns-zone-group"
private_dns_zone_ids = [data.azurerm_private_dns_zone.function_app.id]
}

tags = var.tags
}
2 changes: 1 addition & 1 deletion src/domains/cgn/prod/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ locals {
project = "${local.prefix}-${local.env_short}"

location = "westeurope"
secondary_location = "northeurope"
secondary_location = "italynorth"

tags = {
CostCenter = "TS310 - PAGAMENTI & SERVIZI"
Expand Down
6 changes: 3 additions & 3 deletions src/domains/eucovidcert/_modules/function_apps/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ data "azurerm_subnet" "snet_backendl2" {
resource_group_name = local.resource_group_name_common
}

data "azurerm_subnet" "snet_pblevtdispatcher" {
name = "fnpblevtdispatcherout"
data "azurerm_subnet" "snet_backendl3" {
name = "appbackendl3"
virtual_network_name = local.vnet_name_common
resource_group_name = local.resource_group_name_common
}
Expand Down Expand Up @@ -112,4 +112,4 @@ data "azurerm_key_vault_secret" "fn_eucovidcert_FNSERVICES_API_KEY" {
data "azurerm_monitor_action_group" "error_action_group" {
name = "${replace("${var.project}", "-", "")}error"
resource_group_name = local.resource_group_name_common
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module "function_eucovidcert" {
var.subnet_id,
data.azurerm_subnet.snet_backendl1.id,
data.azurerm_subnet.snet_backendl2.id,
data.azurerm_subnet.snet_pblevtdispatcher.id,
data.azurerm_subnet.snet_apim_v2.id,
data.azurerm_subnet.snet_backendl3.id
]

tags = var.tags
Expand Down Expand Up @@ -77,8 +77,8 @@ module "function_eucovidcert_staging_slot" {
var.subnet_id,
data.azurerm_subnet.snet_backendl1.id,
data.azurerm_subnet.snet_backendl2.id,
data.azurerm_subnet.snet_pblevtdispatcher.id,
data.azurerm_subnet.snet_apim_v2.id,
data.azurerm_subnet.snet_backendl3.id
]

tags = var.tags
Expand Down
6 changes: 6 additions & 0 deletions src/domains/messages-app/01_network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ data "azurerm_subnet" "app_backendl2_snet" {
resource_group_name = local.vnet_common_resource_group_name
}

data "azurerm_subnet" "app_backendl3_snet" {
name = "appbackendl3"
virtual_network_name = local.vnet_common_name
resource_group_name = local.vnet_common_resource_group_name
}

data "azurerm_subnet" "apim_snet" {
name = "apimv2api"
virtual_network_name = local.vnet_common_name
Expand Down
2 changes: 2 additions & 0 deletions src/domains/messages-app/10_function_messages.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ module "app_messages_function" {
data.azurerm_subnet.app_backendl1_snet.id,
data.azurerm_subnet.app_backendl2_snet.id,
data.azurerm_subnet.apim_snet.id,
data.azurerm_subnet.app_backendl3_snet.id
]

allowed_ips = concat(
Expand Down Expand Up @@ -221,6 +222,7 @@ module "app_messages_function_staging_slot" {
data.azurerm_subnet.app_backendl1_snet.id,
data.azurerm_subnet.app_backendl2_snet.id,
data.azurerm_subnet.azdoa_snet.id,
data.azurerm_subnet.app_backendl3_snet.id
]

allowed_ips = concat(
Expand Down
4 changes: 3 additions & 1 deletion src/domains/messages-app/10_function_messages_xl.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ module "app_messages_function_xl" {
data.azurerm_subnet.app_backendl1_snet.id,
data.azurerm_subnet.app_backendl2_snet.id,
data.azurerm_subnet.apim_snet.id,
data.azurerm_subnet.app_backendl3_snet.id
]

allowed_ips = concat(
Expand Down Expand Up @@ -147,6 +148,7 @@ module "app_messages_function_staging_slot_xl" {
data.azurerm_subnet.app_backendl2_snet.id,
data.azurerm_subnet.azdoa_snet.id,
data.azurerm_subnet.github_snet.id,
data.azurerm_subnet.app_backendl3_snet.id
]

allowed_ips = concat(
Expand Down Expand Up @@ -622,4 +624,4 @@ resource "azurerm_subnet_nat_gateway_association" "net_gateway_association_subne
count = var.app_messages_count
nat_gateway_id = data.azurerm_nat_gateway.nat_gateway.id
subnet_id = module.app_messages_snet_xl[count.index].id
}
}
1 change: 1 addition & 0 deletions src/domains/messages-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
| [azurerm_subnet.apim_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.app_backendl1_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.app_backendl2_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.app_backendl3_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.azdoa_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.github_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.private_endpoints_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
Expand Down

0 comments on commit 1dc1e98

Please sign in to comment.