infra/main: add helpful fields to database users list

This commit is contained in:
ryan-distrust.co 2023-05-12 00:54:07 -04:00
parent 58f9f507de
commit b0d3b00b81
Signed by untrusted user who does not match committer: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 17 additions and 2 deletions

View File

@ -57,6 +57,17 @@ module "digitalocean_database_cluster" {
digitalocean_region = var.region
}
locals {
database_host = module.digitalocean_database_cluster.database_cluster.private_host
database_port = module.digitalocean_database_cluster.database_cluster.port
database_jdbc_uri_prefix = join("", [
"jdbc:postgresql://",
module.digitalocean_database_cluster.database_cluster.private_host,
":",
module.digitalocean_database_cluster.database_cluster.port,
])
}
# `jq .database_users.value.forgejo | sops --encrypt`
output "database_users" {
value = {
@ -70,9 +81,13 @@ output "database_users" {
stringData = {
name = db_user.name,
dbname = db_user.name,
host = module.digitalocean_database_cluster.database_cluster.private_host,
port = module.digitalocean_database_cluster.database_cluster.port,
host = local.database_host,
port = local.database_port,
password = db_user.password,
# Forgejo, they call it "host"
address = join(":", [local.database_host, local.database_port]),
# Keycloak
jdbc_url = "${local.database_jdbc_uri_prefix}/${db_user.name}?sslmode=require",
}
}
}