infrastructure/modules/services/postgresql.tf

18 lines
505 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.key
login = true
password = random_password.postgresql_service_passwords[each.key].result
}
resource "postgresql_database" "service_databases" {
for_each = local.services_database
name = each.key
owner = postgresql_role.service_roles[each.key].name
}