2024-09-27 23:59:53 +00:00
|
|
|
resource "random_password" "postgresql_service_passwords" {
|
2024-09-28 16:24:07 +00:00
|
|
|
for_each = local.services_database
|
2024-09-27 23:59:53 +00:00
|
|
|
length = 32
|
|
|
|
special = false
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "postgresql_role" "service_roles" {
|
2024-09-28 16:24:07 +00:00
|
|
|
for_each = local.services_database
|
2024-09-27 23:59:53 +00:00
|
|
|
name = each.value.name
|
|
|
|
login = true
|
|
|
|
password = random_password.postgresql_service_passwords[each.key].result
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "postgresql_database" "service_databases" {
|
2024-09-28 16:24:07 +00:00
|
|
|
for_each = local.services_database
|
2024-09-27 23:59:53 +00:00
|
|
|
name = each.value.name
|
|
|
|
owner = postgresql_role.service_roles[each.key].name
|
|
|
|
}
|