Skip to content

Commit 2193acb

Browse files
committed
Add private endpoint for Function
1 parent b353ff9 commit 2193acb

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

.github/workflows/terraform.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/workflows/_terraformApplyTemplate.yml
3939
name: "Terraform Apply"
4040
needs: [terraform_plan_dev]
41-
if: github.event_name == 'push' || github.event_name == 'release'
41+
# if: github.event_name == 'push' || github.event_name == 'release'
4242
with:
4343
environment: "dev"
4444
terraform_version: "1.4.6"

code/infra/function.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,25 @@ resource "azurerm_monitor_diagnostic_setting" "diagnostic_setting_function" {
131131
}
132132
}
133133
}
134+
135+
resource "azurerm_private_endpoint" "function_private_endpoint" {
136+
name = "${azapi_resource.function.name}-pe"
137+
location = var.location
138+
resource_group_name = azurerm_resource_group.app_rg.name
139+
tags = var.tags
140+
141+
custom_network_interface_name = "${azapi_resource.function.name}-nic"
142+
private_service_connection {
143+
name = "${azapi_resource.function.name}-pe"
144+
is_manual_connection = false
145+
private_connection_resource_id = azapi_resource.function.id
146+
subresource_names = ["sites"]
147+
}
148+
subnet_id = azapi_resource.subnet_services.id
149+
private_dns_zone_group {
150+
name = "${azapi_resource.function.name}-arecord"
151+
private_dns_zone_ids = [
152+
var.private_dns_zone_id_sites
153+
]
154+
}
155+
}

code/infra/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,14 @@ variable "private_dns_zone_id_key_vault" {
116116
error_message = "Please specify a valid resource ID for the private DNS Zone."
117117
}
118118
}
119+
120+
variable "private_dns_zone_id_sites" {
121+
description = "Specifies the resource ID of the private DNS zone for Azure Websites. Not required if DNS A-records get created via Azue Policy."
122+
type = string
123+
sensitive = false
124+
default = ""
125+
validation {
126+
condition = var.private_dns_zone_id_sites == "" || (length(split("/", var.private_dns_zone_id_sites)) == 9 && endswith(var.private_dns_zone_id_sites, "privatelink.azurewebsites.net"))
127+
error_message = "Please specify a valid resource ID for the private DNS Zone."
128+
}
129+
}

code/infra/vars.dev.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ private_dns_zone_id_queue = "/subscriptions/8f171ff9-2b5b-4f0f-aed5-7fa360a1
1010
private_dns_zone_id_table = "/subscriptions/8f171ff9-2b5b-4f0f-aed5-7fa360a1d094/resourceGroups/mycrp-prd-global-dns/providers/Microsoft.Network/privateDnsZones/privatelink.table.core.windows.net"
1111
private_dns_zone_id_file = "/subscriptions/8f171ff9-2b5b-4f0f-aed5-7fa360a1d094/resourceGroups/mycrp-prd-global-dns/providers/Microsoft.Network/privateDnsZones/privatelink.file.core.windows.net"
1212
private_dns_zone_id_key_vault = "/subscriptions/8f171ff9-2b5b-4f0f-aed5-7fa360a1d094/resourceGroups/mycrp-prd-global-dns/providers/Microsoft.Network/privateDnsZones/privatelink.vaultcore.azure.net"
13+
private_dns_zone_id_sites = "/subscriptions/8f171ff9-2b5b-4f0f-aed5-7fa360a1d094/resourceGroups/mycrp-prd-global-dns/providers/Microsoft.Network/privateDnsZones/privatelink.azurewebsites.net"

0 commit comments

Comments
 (0)