Skip to content

Commit 438365a

Browse files
authored
Merge pull request #156 from PerfectThymeTech/marvinbuss/private_endpoints
Enable creation of additional external private endpoints per app
2 parents 273fcbf + c6eea2a commit 438365a

File tree

6 files changed

+85
-1
lines changed

6 files changed

+85
-1
lines changed

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ module "data_application" {
9696
storage_account_ids = module.core.storage_account_ids
9797
databricks_workspace_details = module.core.databricks_workspace_details
9898
ai_services = try(each.value.ai_services, {})
99+
private_endpoints = try(each.value.private_endpoints, {})
99100
search_service_details = try(each.value.ai_search, {})
100101
data_factory_details = {
101102
enabled = try(each.value.data_factory.enabled, false)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
resource "azurerm_private_endpoint" "private_endpoint" {
2+
for_each = var.private_endpoints
3+
4+
name = "${local.prefix}-${each.key}-pe"
5+
resource_group_name = azurerm_resource_group.resource_group_app.name
6+
location = var.location
7+
8+
custom_network_interface_name = "${local.prefix}-${each.key}-nic"
9+
private_service_connection {
10+
name = "${local.prefix}-${each.key}-svc"
11+
is_manual_connection = true
12+
private_connection_resource_id = each.value.resource_id
13+
request_message = "Private Endpoint Connection Request from Data Landing Zone Stamp Application with prefix: ${local.prefix}"
14+
subresource_names = [each.value.subresource_name]
15+
}
16+
subnet_id = var.subnet_id_app
17+
dynamic "private_dns_zone_group" {
18+
for_each = each.value.private_dns_zone_id == "" ? [] : [1]
19+
content {
20+
name = "${local.prefix}-${each.key}-arecord"
21+
private_dns_zone_ids = [
22+
each.value.private_dns_zone_id
23+
]
24+
}
25+
}
26+
27+
lifecycle {
28+
ignore_changes = [
29+
private_dns_zone_group
30+
]
31+
}
32+
}

modules/dataapplication/variables.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,25 @@ variable "ai_services" {
108108
}
109109
}
110110

111+
variable "private_endpoints" {
112+
description = "Specifies the map of private endpoints to be created for this application."
113+
type = map(object({
114+
resource_id = string
115+
subresource_name = string
116+
private_dns_zone_id = optional(string, "")
117+
}))
118+
sensitive = false
119+
nullable = false
120+
default = {}
121+
validation {
122+
condition = alltrue([
123+
length([for resource_id in values(var.private_endpoints)[*].resource_id : resource_id if length(split("/", resource_id)) != 9]) <= 0,
124+
length([for private_dns_zone_id in values(var.private_endpoints)[*].private_dns_zone_id : private_dns_zone_id if(private_dns_zone_id != "" && length(split("/", private_dns_zone_id)) != 9)]) <= 0,
125+
])
126+
error_message = "Please specify a valid ai service configuration."
127+
}
128+
}
129+
111130
variable "data_factory_details" {
112131
description = "Specifies the data factory configuration details."
113132
type = object({

schemas/app.schema.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,33 @@
310310
}
311311
}
312312
},
313+
"private_endpoints": {
314+
"description": "Specifies the private endpoints to be deployed for the application.",
315+
"type": "object",
316+
"patternProperties": {
317+
"^.*$": {
318+
"properties": {
319+
"resource_id": {
320+
"description": "Specifies the resource id to which the private endpoint should connect.",
321+
"type": "string"
322+
},
323+
"subresource_name": {
324+
"description": "Specifies the subresource name of the private endpoint.",
325+
"type": "string"
326+
},
327+
"private_dns_zone_id": {
328+
"description": "Specifies the private dns zone for the private endpoint.",
329+
"type": "string"
330+
}
331+
},
332+
"required": [
333+
"resource_id",
334+
"subresource_name"
335+
],
336+
"additionalProperties": false
337+
}
338+
}
339+
},
313340
"ai_search": {
314341
"description": "Specifies the ai search configuration for the app.",
315342
"type": "object",

tests/e2e/data-applications/app001.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ ai_search:
5454

5555
data_factory:
5656
enabled: true
57+
58+
private_endpoints:
59+
stg:
60+
resource_id: "/subscriptions/1fdab118-1638-419a-8b12-06c9543714a0/resourceGroups/tfmodule-test-rg/providers/Microsoft.Storage/storageAccounts/mytfteststg"
61+
subresource_name: "blob"

tests/e2e/terraform.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
azurerm = {
66
source = "hashicorp/azurerm"
7-
version = "4.19.0"
7+
version = "4.20.0"
88
}
99
azapi = {
1010
source = "azure/azapi"

0 commit comments

Comments
 (0)