-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.tf
71 lines (69 loc) · 2.61 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
variable "postgresql_server" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "postgresql_database" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
variable "postgresql_firewall_rule" {
type = any
default = {}
description = "resource definition, default settings are defined within locals and merged with var settings"
}
locals {
default = {
# resource definition
postgresql_server = {
name = ""
administrator_login = null
administrator_login_password = null
auto_grow_enabled = false
backup_retention_days = null
create_mode = "Default"
creation_source_server_id = null
geo_redundant_backup_enabled = null
infrastructure_encryption_enabled = false
public_network_access_enabled = false
restore_point_in_time = null
ssl_enforcement_enabled = true
ssl_minimal_tls_version_enforced = null
storage_mb = null
identity = {}
threat_detection_policy = {}
tags = {}
}
postgresql_database = {
name = ""
}
postgresql_firewall_rule = {
name = ""
}
}
# compare and merge custom and default values
postgresql_server_values = {
for postgresql_server in keys(var.postgresql_server) :
postgresql_server => merge(local.default.postgresql_server, var.postgresql_server[postgresql_server])
}
# merge all custom and default values
postgresql_server = {
for postgresql_server in keys(var.postgresql_server) :
postgresql_server => merge(
local.postgresql_server_values[postgresql_server],
{
for config in ["identity", "threat_detection_policy"] :
config => merge(local.default.postgresql_server[config], local.postgresql_server_values[postgresql_server][config])
}
)
}
postgresql_database = {
for postgresql_database in keys(var.postgresql_database) :
postgresql_database => merge(local.default.postgresql_database, var.postgresql_database[postgresql_database])
}
postgresql_firewall_rule = {
for postgresql_firewall_rule in keys(var.postgresql_firewall_rule) :
postgresql_firewall_rule => merge(local.default.postgresql_firewall_rule, var.postgresql_firewall_rule[postgresql_firewall_rule])
}
}