-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.tf
140 lines (136 loc) · 4.88 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
variable "cosmosdb_account" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "cosmosdb_mongo_collection" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "cosmosdb_mongo_database" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
locals {
default = {
# resource definition
cosmosdb_account = {
name = ""
offer_type = "Standard"
create_mode = null
default_identity_type = "FirstPartyIdentity"
kind = "MongoDB"
ip_range_filter = null
enable_free_tier = false
analytical_storage_enabled = false
enable_automatic_failover = true
public_network_access_enabled = true
is_virtual_network_filter_enabled = true
key_vault_key_id = null
enable_multiple_write_locations = false
access_key_metadata_writes_enabled = true
network_acl_bypass_for_azure_services = false
network_acl_bypass_ids = null
local_authentication_disabled = false
consistency_policy = {
consistency_level = "Strong"
max_interval_in_seconds = null
max_staleness_prefix = null
}
geo_location = {
location = ""
failover_priority = 0
zone_redundant = false
}
capabilities = null
virtual_network_rule = {
id = ""
ignore_missing_vnet_service_endpoint = false
}
analytical_storage = {}
capacity = {}
backup = {
type = ""
interval_in_minutes = null
retention_in_hours = null
storage_redundancy = null
}
cors_rule = {}
identity = {}
restore = {
source_cosmosdb_account_id = ""
database = null
}
tags = {}
}
cosmosdb_mongo_collection = {
name = ""
analytical_storage_ttl = null
default_ttl_seconds = null
throughput = null
index = {}
autoscale_settings = {}
}
cosmosdb_mongo_database = {
throughput = null
autoscale_settings = {}
}
}
# compare and merge custom and default values
cosmosdb_account_values = {
for cosmosdb_account in keys(var.cosmosdb_account) :
cosmosdb_account => merge(local.default.cosmosdb_account, var.cosmosdb_account[cosmosdb_account])
}
cosmosdb_mongo_collection_values = {
for cosmosdb_mongo_collection in keys(var.cosmosdb_mongo_collection) :
cosmosdb_mongo_collection => merge(local.default.cosmosdb_mongo_collection, var.cosmosdb_mongo_collection[cosmosdb_mongo_collection])
}
cosmosdb_mongo_database_values = {
for cosmosdb_mongo_database in keys(var.cosmosdb_mongo_database) :
cosmosdb_mongo_database => merge(local.default.cosmosdb_mongo_database, var.cosmosdb_mongo_database[cosmosdb_mongo_database])
}
# merge all custom and default values
cosmosdb_account = {
for cosmosdb_account in keys(var.cosmosdb_account) :
cosmosdb_account => merge(
local.cosmosdb_account_values[cosmosdb_account],
{
for config in [
"consistency_policy",
"geo_location",
"capabilities",
"virtual_network_rule",
"analytical_storage",
"capacity",
"backup",
"cors_rule",
"identity",
"restore",
] :
config => merge(local.default.cosmosdb_account[config], local.cosmosdb_account_values[cosmosdb_account][config])
}
)
}
cosmosdb_mongo_collection = {
for cosmosdb_mongo_collection in keys(var.cosmosdb_mongo_collection) :
cosmosdb_mongo_collection => merge(
local.cosmosdb_mongo_collection_values[cosmosdb_mongo_collection],
{
for config in ["autoscale_settings", "index"] :
config => merge(local.default.cosmosdb_mongo_collection[config], local.cosmosdb_mongo_collection_values[cosmosdb_mongo_collection][config])
}
)
}
cosmosdb_mongo_database = {
for cosmosdb_mongo_database in keys(var.cosmosdb_mongo_database) :
cosmosdb_mongo_database => merge(
local.cosmosdb_mongo_database_values[cosmosdb_mongo_database],
{
for config in ["autoscale_settings"] :
config => merge(local.default.cosmosdb_mongo_database[config], local.cosmosdb_mongo_database_values[cosmosdb_mongo_database][config])
}
)
}
}