-
Notifications
You must be signed in to change notification settings - Fork 5
/
variables.tf
208 lines (205 loc) · 6.98 KB
/
variables.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
variable "dns_zone" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "private_dns_zone" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "dns_a_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "private_dns_a_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "dns_cname_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "private_dns_cname_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "dns_txt_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "private_dns_txt_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "dns_mx_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "private_dns_mx_record" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "private_dns_zone_virtual_network_link" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
locals {
default = {
// resource definition
dns_zone = {
name = ""
soa_record = {
host_name = null
expire_time = null
minimum_ttl = null
refresh_time = null
retry_time = null
serial_number = null
ttl = null
tags = null
}
tags = {}
}
private_dns_zone = {
name = ""
soa_record = {
host_name = null
expire_time = null
minimum_ttl = null
refresh_time = null
retry_time = null
serial_number = null
ttl = null
tags = null
}
tags = {}
}
dns_a_record = {
name = ""
ttl = 3600 // define default
records = null
target_resource_id = null
tags = {}
}
private_dns_a_record = {
name = ""
ttl = 3600 // define default
records = null
tags = {}
}
dns_cname_record = {
name = ""
ttl = 3600 // define default
record = null
target_resource_id = null
tags = {}
}
private_dns_cname_record = {
name = ""
ttl = 3600 // define default
record = null
tags = {}
}
dns_txt_record = {
name = ""
ttl = 3600 // define default
tags = {}
}
private_dns_txt_record = {
name = ""
ttl = 3600 // define default
tags = {}
}
dns_mx_record = {
name = ""
ttl = 3600 // define default
tags = {}
}
private_dns_mx_record = {
name = ""
ttl = 3600 // define default
tags = {}
}
private_dns_zone_virtual_network_link = {
name = ""
registration_enabled = null
tags = {}
}
}
// compare and merge custom and default values
dns_zone_values = {
for dns_zone in keys(var.dns_zone) :
dns_zone => merge(local.default.dns_zone, var.dns_zone[dns_zone])
}
private_dns_zone_values = {
for private_dns_zone in keys(var.private_dns_zone) :
private_dns_zone => merge(local.default.private_dns_zone, var.private_dns_zone[private_dns_zone])
}
// deep merge of all custom and default values
dns_zone = {
for dns_zone in keys(var.dns_zone) :
dns_zone => merge(
local.dns_zone_values[dns_zone],
{
for config in ["soa_record"] :
config => keys(local.dns_zone_values[dns_zone][config]) == keys(local.default.dns_zone[config]) ? null : merge(local.default.dns_zone[config], local.dns_zone_values[dns_zone][config])
}
)
}
private_dns_zone = {
for private_dns_zone in keys(var.private_dns_zone) :
private_dns_zone => merge(
local.private_dns_zone_values[private_dns_zone],
{
for config in ["soa_record"] :
config => keys(local.private_dns_zone_values[private_dns_zone][config]) == keys(local.default.private_dns_zone[config]) ? null : merge(local.default.private_dns_zone[config], local.private_dns_zone_values[private_dns_zone][config])
}
)
}
dns_a_record = {
for dns_a_record in keys(var.dns_a_record) :
dns_a_record => merge(local.default.dns_a_record, var.dns_a_record[dns_a_record])
}
private_dns_a_record = {
for private_dns_a_record in keys(var.private_dns_a_record) :
private_dns_a_record => merge(local.default.private_dns_a_record, var.private_dns_a_record[private_dns_a_record])
}
dns_cname_record = {
for dns_cname_record in keys(var.dns_cname_record) :
dns_cname_record => merge(local.default.dns_cname_record, var.dns_cname_record[dns_cname_record])
}
private_dns_cname_record = {
for private_dns_cname_record in keys(var.private_dns_cname_record) :
private_dns_cname_record => merge(local.default.private_dns_cname_record, var.private_dns_cname_record[private_dns_cname_record])
}
dns_txt_record = {
for dns_txt_record in keys(var.dns_txt_record) :
dns_txt_record => merge(local.default.dns_txt_record, var.dns_txt_record[dns_txt_record])
}
private_dns_txt_record = {
for private_dns_txt_record in keys(var.private_dns_txt_record) :
private_dns_txt_record => merge(local.default.private_dns_txt_record, var.private_dns_txt_record[private_dns_txt_record])
}
dns_mx_record = {
for dns_mx_record in keys(var.dns_mx_record) :
dns_mx_record => merge(local.default.dns_mx_record, var.dns_mx_record[dns_mx_record])
}
private_dns_mx_record = {
for private_dns_mx_record in keys(var.private_dns_mx_record) :
private_dns_mx_record => merge(local.default.private_dns_mx_record, var.private_dns_mx_record[private_dns_mx_record])
}
private_dns_zone_virtual_network_link = {
for private_dns_zone_virtual_network_link in keys(var.private_dns_zone_virtual_network_link) :
private_dns_zone_virtual_network_link => merge(local.default.private_dns_zone_virtual_network_link, var.private_dns_zone_virtual_network_link[private_dns_zone_virtual_network_link])
}
}