-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathr-private-dns-resolver.tf
113 lines (83 loc) · 3.86 KB
/
r-private-dns-resolver.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
resource "azurerm_private_dns_resolver" "main" {
name = local.name
location = var.location
resource_group_name = var.resource_group_name
virtual_network_id = local.virtual_network_id
tags = merge(local.default_tags, var.extra_tags)
}
moved {
from = azurerm_private_dns_resolver.private_dns_resolver
to = azurerm_private_dns_resolver.main
}
resource "azurerm_private_dns_resolver_inbound_endpoint" "main" {
for_each = local.inbound_endpoints
name = coalesce(each.value.custom_name, data.azurecaf_name.inbound_endpoints[each.key].result)
location = azurerm_private_dns_resolver.main.location
private_dns_resolver_id = azurerm_private_dns_resolver.main.id
ip_configurations {
private_ip_allocation_method = "Dynamic"
subnet_id = module.subnets[each.key].id
}
tags = merge(local.default_tags, var.extra_tags)
}
moved {
from = azurerm_private_dns_resolver_inbound_endpoint.inbound_endpoints
to = azurerm_private_dns_resolver_inbound_endpoint.main
}
resource "azurerm_private_dns_resolver_outbound_endpoint" "main" {
for_each = local.outbound_endpoints
name = coalesce(each.value.custom_name, data.azurecaf_name.outbound_endpoints[each.key].result)
location = azurerm_private_dns_resolver.main.location
private_dns_resolver_id = azurerm_private_dns_resolver.main.id
subnet_id = module.subnets[each.key].id
tags = merge(local.default_tags, var.extra_tags)
}
moved {
from = azurerm_private_dns_resolver_outbound_endpoint.outbound_endpoints
to = azurerm_private_dns_resolver_outbound_endpoint.main
}
resource "azurerm_private_dns_resolver_dns_forwarding_ruleset" "main" {
for_each = local.dns_forwarding_rulesets
name = coalesce(each.value.custom_name, data.azurecaf_name.dns_forwarding_rulesets[each.key].result)
location = azurerm_private_dns_resolver.main.location
resource_group_name = var.resource_group_name
private_dns_resolver_outbound_endpoint_ids = [
for endpoint in each.value.target_outbound_endpoints : length(regexall(
"^\\/(subscriptions)\\/([a-z0-9\\-]+)\\/(resourceGroups)\\/([A-Za-z0-9\\-]+)\\/(providers)\\/(Microsoft.Network)\\/(dnsResolvers)\\/([A-Za-z0-9\\-]+)\\/(outboundEndpoints)\\/([A-Za-z0-9\\-]+)$", endpoint
)) == 1 ? endpoint : azurerm_private_dns_resolver_outbound_endpoint.main[format("%s-%s", endpoint, "outbe")].id
]
tags = merge(local.default_tags, var.extra_tags)
}
moved {
from = azurerm_private_dns_resolver_dns_forwarding_ruleset.dns_forwarding_rulesets
to = azurerm_private_dns_resolver_dns_forwarding_ruleset.main
}
resource "azurerm_private_dns_resolver_forwarding_rule" "main" {
for_each = local.forwarding_rules
name = coalesce(each.value.custom_name, data.azurecaf_name.forwarding_rules[each.key].result)
dns_forwarding_ruleset_id = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[each.value.ruleset_name].id
domain_name = each.value.domain_name
enabled = each.value.enabled
dynamic "target_dns_servers" {
for_each = each.value.dns_servers_ips
iterator = item
content {
ip_address = item.value
port = 53 # Fixed value
}
}
}
moved {
from = azurerm_private_dns_resolver_forwarding_rule.forwarding_rules
to = azurerm_private_dns_resolver_forwarding_rule.main
}
resource "azurerm_private_dns_resolver_virtual_network_link" "main" {
count = length(local.virtual_network_links_flattened)
name = local.virtual_network_links_flattened[count.index].name
dns_forwarding_ruleset_id = azurerm_private_dns_resolver_dns_forwarding_ruleset.main[local.virtual_network_links_flattened[count.index].ruleset_name].id
virtual_network_id = local.virtual_network_links_flattened[count.index].virtual_network_id
}
moved {
from = azurerm_private_dns_resolver_virtual_network_link.vnet_links
to = azurerm_private_dns_resolver_virtual_network_link.main
}