From b0d3b00b817fb7b4d1411a77aabf2275d7c7c924 Mon Sep 17 00:00:00 2001 From: "ryan-distrust.co" Date: Fri, 12 May 2023 00:54:07 -0400 Subject: [PATCH] infra/main: add helpful fields to database users list --- infra/main/main.tf | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/infra/main/main.tf b/infra/main/main.tf index 5162ba2..b298628 100644 --- a/infra/main/main.tf +++ b/infra/main/main.tf @@ -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", } } }