-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.privateendpoint.tf
76 lines (65 loc) · 3.39 KB
/
main.privateendpoint.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# The PE resource when we are managing the private_dns_zone_group block:
resource "azurerm_private_endpoint" "this" {
for_each = { for k, v in var.private_endpoints : k => v if var.private_endpoints_manage_dns_zone_group }
location = coalesce(each.value.location, var.location)
name = each.value.name != null ? each.value.name : "pe-${var.name}"
resource_group_name = each.value.resource_group_name != null ? each.value.resource_group_name : var.resource_group_name
subnet_id = each.value.subnet_resource_id
custom_network_interface_name = each.value.network_interface_name
tags = each.value.tags
private_service_connection {
is_manual_connection = false
name = each.value.private_service_connection_name != null ? each.value.private_service_connection_name : "pse-${var.name}"
private_connection_resource_id = azurerm_container_registry.this.id
subresource_names = ["registry"]
}
dynamic "ip_configuration" {
for_each = each.value.ip_configurations
content {
name = ip_configuration.value.name
private_ip_address = ip_configuration.value.private_ip_address
member_name = "registry"
subresource_name = "registry"
}
}
dynamic "private_dns_zone_group" {
for_each = length(each.value.private_dns_zone_resource_ids) > 0 ? ["this"] : []
content {
name = each.value.private_dns_zone_group_name
private_dns_zone_ids = each.value.private_dns_zone_resource_ids
}
}
}
# The PE resource when we are **not** managing the private_dns_zone_group block, such as when using Azure Policy:
resource "azurerm_private_endpoint" "this_unmanaged_dns_zone_groups" {
for_each = { for k, v in var.private_endpoints : k => v if !var.private_endpoints_manage_dns_zone_group }
location = coalesce(each.value.location, var.location)
name = each.value.name != null ? each.value.name : "pe-${var.name}"
resource_group_name = each.value.resource_group_name != null ? each.value.resource_group_name : var.resource_group_name
subnet_id = each.value.subnet_resource_id
custom_network_interface_name = each.value.network_interface_name
tags = each.value.tags
private_service_connection {
is_manual_connection = false
name = each.value.private_service_connection_name != null ? each.value.private_service_connection_name : "pse-${var.name}"
private_connection_resource_id = azurerm_container_registry.this.id
subresource_names = ["registry"]
}
dynamic "ip_configuration" {
for_each = each.value.ip_configurations
content {
name = ip_configuration.value.name
private_ip_address = ip_configuration.value.private_ip_address
member_name = "registry"
subresource_name = "registry"
}
}
lifecycle {
ignore_changes = [private_dns_zone_group]
}
}
resource "azurerm_private_endpoint_application_security_group_association" "this" {
for_each = local.private_endpoint_application_security_group_associations
application_security_group_id = each.value.asg_resource_id
private_endpoint_id = azurerm_private_endpoint.this[each.value.pe_key].id
}