From 7df25413e018b8297864fb65b2408fc3b84ada05 Mon Sep 17 00:00:00 2001 From: christian-calabrese Date: Tue, 6 Aug 2024 10:52:37 +0200 Subject: [PATCH] feat: add private endpoint to submigrations selfcare function --- .../selfcare/_modules/app_services/data.tf | 5 +++ .../function_subscription_migrations.tf | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/domains/selfcare/_modules/app_services/data.tf b/src/domains/selfcare/_modules/app_services/data.tf index 2148cb7e1..4b441852a 100644 --- a/src/domains/selfcare/_modules/app_services/data.tf +++ b/src/domains/selfcare/_modules/app_services/data.tf @@ -132,3 +132,8 @@ data "azurerm_storage_account" "assets_cdn" { name = replace("${var.project}-stcdnassets", "-", "") 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 +} diff --git a/src/domains/selfcare/_modules/app_services/function_subscription_migrations.tf b/src/domains/selfcare/_modules/app_services/function_subscription_migrations.tf index 4b70fc1bf..7df653afd 100644 --- a/src/domains/selfcare/_modules/app_services/function_subscription_migrations.tf +++ b/src/domains/selfcare/_modules/app_services/function_subscription_migrations.tf @@ -101,3 +101,45 @@ module "function_subscriptionmigrations_staging_slot" { tags = var.tags } + +resource "azurerm_private_endpoint" "function_sites" { + name = "${var.project}-subsmigrations-fn" + location = var.location + resource_group_name = var.resource_group_name + subnet_id = var.private_endpoint_subnet_id + + private_service_connection { + name = "${var.project}-subsmigrations-fn" + private_connection_resource_id = module.function_subscriptionmigrations.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}-subsmigrations-fn-staging" + location = var.location + resource_group_name = var.resource_group_name + subnet_id = var.private_endpoint_subnet_id + + private_service_connection { + name = "${var.project}-subsmigrations-fn-staging" + private_connection_resource_id = module.function_subscriptionmigrations.id + is_manual_connection = false + subresource_names = ["sites-${module.function_subscriptionmigrations.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 +} \ No newline at end of file