-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvariables.tf
239 lines (236 loc) · 8.69 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
variable "storage_account" {
type = any
default = {}
description = "Resource definition, default settings are defined within locals and merged with var settings. For more information look at [Outputs](#Outputs)."
}
variable "storage_container" {
type = any
default = {}
description = "Resource definition, default settings are defined within locals and merged with var settings. For more information look at [Outputs](#Outputs)."
}
variable "storage_share" {
type = any
default = {}
description = "Resource definition, default settings are defined within locals and merged with var settings. For more information look at [Outputs](#Outputs)."
}
variable "storage_share_directory" {
type = any
default = {}
description = "Resource definition, default settings are defined within locals and merged with var settings. For more information look at [Outputs](#Outputs)."
}
locals {
default = {
// resource definition
storage_account = {
name = ""
account_kind = null
account_tier = "Standard" // defined default
account_replication_type = "ZRS" // defined default
cross_tenant_replication_enabled = false
access_tier = null
edge_zone = null
enable_https_traffic_only = null
min_tls_version = null
allow_nested_items_to_be_public = false // defined default
shared_access_key_enabled = null
public_network_access_enabled = null
default_to_oauth_authentication = null
is_hns_enabled = null
nfsv3_enabled = null
large_file_share_enabled = null
queue_encryption_key_type = null
table_encryption_key_type = null
infrastructure_encryption_enabled = null
allowed_copy_scope = null
sftp_enabled = null
custom_domain = {
name = ""
use_subdomain = null
}
customer_managed_key = {}
identity = {
identity_ids = null
}
blob_properties = {
versioning_enabled = null
change_feed_enabled = null
change_feed_retention_in_days = null
default_service_version = null
last_access_time_enabled = null
cors_rule = {}
delete_retention_policy = {
days = null
}
restore_policy = {}
container_delete_retention_policy = {
days = null
}
}
queue_properties = {
cors_rule = {}
logging = {
retention_policy_days = null
}
minute_metrics = {
include_apis = null
retention_policy_days = null
}
hour_metrics = {
include_apis = null
retention_policy_days = null
}
}
static_website = {
index_document = null
error_404_document = null
}
share_properties = {
cors_rule = {}
retention_policy = {
days = null
}
smb = {
versions = null
authentication_types = null
kerberos_ticket_encryption_type = null
channel_encryption_type = null
multichannel_enabled = null
}
}
network_rules = {
bypass = null
default_action = "Deny" // defined default
ip_rules = null
virtual_network_subnet_ids = null
private_link_access = {
endpoint_tenant_id = null
}
}
azure_files_authentication = {
directory_type = ""
active_directory = {}
}
routing = {
publish_internet_endpoints = null
publish_microsoft_endpoints = null
choice = null
}
immutability_policy = {}
sas_policy = {
expiration_action = null
}
tags = {}
}
storage_container = {
name = ""
container_access_type = null
metadata = null
}
storage_share = {
name = ""
access_tier = "Hot"
enabled_protocol = null
metadata = null
acl = {
access_policy = {
start = null
expiry = null
}
}
}
storage_share_directory = {
name = ""
metadata = null
}
}
// compare and merge custom and default values
storage_account_values = {
for storage_account in keys(var.storage_account) :
storage_account => merge(local.default.storage_account, var.storage_account[storage_account])
}
storage_share_values = {
for storage_share in keys(var.storage_share) :
storage_share => merge(local.default.storage_share, var.storage_share[storage_share])
}
// deep merge of all custom and default values
storage_account = {
for storage_account in keys(var.storage_account) :
storage_account => merge(
local.storage_account_values[storage_account],
{
for config in [
"custom_domain",
"customer_managed_key",
"identity",
"static_website",
"azure_files_authentication",
"routing",
"immutability_policy",
"sas_policy"
] :
config => merge(local.default.storage_account[config], local.storage_account_values[storage_account][config])
},
{
for config in ["blob_properties"] :
config => lookup(var.storage_account[storage_account], config, {}) == {} ? null : merge(
merge(local.default.storage_account[config], local.storage_account_values[storage_account][config]),
{
for subconfig in ["cors_rule", "delete_retention_policy", "restore_policy", "container_delete_retention_policy"] :
subconfig => merge(local.default.storage_account[config][subconfig], lookup(local.storage_account_values[storage_account][config], subconfig, {}))
}
)
},
{
for config in ["queue_properties"] :
config => lookup(var.storage_account[storage_account], config, {}) == {} ? null : merge(
merge(local.default.storage_account[config], local.storage_account_values[storage_account][config]),
{
for subconfig in ["cors_rule", "logging", "minute_metrics", "hour_metrics"] :
subconfig => merge(local.default.storage_account[config][subconfig], lookup(local.storage_account_values[storage_account][config], subconfig, {}))
}
)
},
{
for config in ["share_properties"] :
config => lookup(var.storage_account[storage_account], config, {}) == {} ? null : merge(
merge(local.default.storage_account[config], local.storage_account_values[storage_account][config]),
{
for subconfig in ["cors_rule", "retention_policy", "smb"] :
subconfig => merge(local.default.storage_account[config][subconfig], lookup(local.storage_account_values[storage_account][config], subconfig, {}))
}
)
},
{
for config in ["network_rules"] :
config => lookup(var.storage_account[storage_account], config, {}) == {} ? null : merge(
merge(local.default.storage_account[config], local.storage_account_values[storage_account][config]),
{
for subconfig in ["private_link_access"] :
subconfig => merge(local.default.storage_account[config][subconfig], lookup(local.storage_account_values[storage_account][config], subconfig, {}))
}
)
}
)
}
storage_container = {
for storage_container in keys(var.storage_container) :
storage_container => merge(local.default.storage_container, var.storage_container[storage_container])
}
storage_share = {
for storage_share in keys(var.storage_share) :
storage_share => merge(
local.storage_share_values[storage_share],
{
for config in ["acl"] :
config => keys(local.storage_share_values[storage_share][config]) == keys(local.default.storage_share[config]) ? {} : {
for key in keys(local.storage_share_values[storage_share][config]) :
key => merge(local.default.storage_share[config], local.storage_share_values[storage_share][config][key])
}
}
)
}
storage_share_directory = {
for storage_share_directory in keys(var.storage_share_directory) :
storage_share_directory => merge(local.default.storage_share_directory, var.storage_share_directory[storage_share_directory])
}
}