-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
59 lines (52 loc) · 2.41 KB
/
main.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
module "postgres_rds" {
for_each = local.rds_instance_map
source = "./modules/postgres_rds"
vpc_id = each.value.vpc_id
db_subnet_ids = each.value.db_subnet_ids
identifier = each.key
server_name = each.value.server_name
environment = var.environment
snapshot_identifier = each.value.snapshot_identifier
postgres_version = each.value.postgres_version
auto_minor_version_upgrade = each.value.auto_minor_version_upgrade
instance_class = each.value.instance_class
storage_type = each.value.storage_type
allocated_storage = each.value.allocated_storage
maintenance_database = each.value.maintenance_database
maintenance_username = each.value.maintenance_username
max_allocated_storage = each.value.max_allocated_storage
skip_final_snapshot = each.value.skip_final_snapshot
deletion_protection = each.value.deletion_protection
subnet_group = each.value.subnet_group
storage_encrypted = each.value.storage_encrypted
allowed_cidrs = each.value.allowed_cidrs
existing_user_credentials = each.value.existing_user_credentials
regenerate_password = each.value.regenerate_password
parameter_group = each.value.parameter_group
}
module "postgres_init" {
source = "./modules/postgres_init"
for_each = local.rds_init_map
conn = {
server_name = local.rds_instance_map[module.postgres_rds[each.key].rds_instance.identifier].server_name
environment = var.environment
engine = module.postgres_rds[each.key].rds_instance.engine
host = module.postgres_rds[each.key].rds_instance.address
port = module.postgres_rds[each.key].rds_instance.port
maintenance_user = (
local.rds_instance_map[each.key].existing_user_credentials == null
? module.postgres_rds[each.key].rds_instance.username
: local.rds_instance_map[each.key].existing_user_credentials.username
)
password = (
local.rds_instance_map[each.key].existing_user_credentials == null
? null
: local.rds_instance_map[each.key].existing_user_credentials.password
)
maintenance_database = module.postgres_rds[each.key].rds_instance.db_name
}
users = local.rds_init_map[each.key].users
databases = local.rds_init_map[each.key].databases
scripts = local.rds_init_map[each.key].scripts
depends_on = [module.postgres_rds]
}