infrastructure/modules/services/postgresql.tf

18 lines
519 B
HCL

resource "random_password" "postgresql_service_passwords" {
for_each = local.services_database
length = 32
special = false
}
resource "postgresql_role" "service_roles" {
for_each = local.services_database
name = each.value.name
login = true
password = random_password.postgresql_service_passwords[each.key].result
}
resource "postgresql_database" "service_databases" {
for_each = local.services_database
name = each.value.name
owner = postgresql_role.service_roles[each.key].name
}