infrastructure/modules/services/postgresql.tf

19 lines
505 B
Terraform
Raw Normal View History

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
name = each.key
2024-09-27 23:59:53 +00:00
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
name = each.key
2024-09-27 23:59:53 +00:00
owner = postgresql_role.service_roles[each.key].name
}