We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a Postgres database in my infrastructure. It's defined like this:
resource "digitalocean_database_cluster" "postgres" { name = "bee-db-cluster-postgres" engine = "pg" version = "16" size = "db-s-1vcpu-1gb" region = "sfo2" node_count = 1 } resource "digitalocean_database_db" "postgres" { cluster_id = digitalocean_database_cluster.postgres.id name = "bee" provisioner "local-exec" { command = <<EOF # assumes psql is available locally psql -f ../backend/sql-scripts/1-schema.sql psql -f ../backend/sql-scripts/2-triggers.sql psql -f ../backend/sql-scripts/3-views.sql psql -f ../backend/sql-scripts/100-seed.sql EOF environment = { "PGUSER" = digitalocean_database_cluster.postgres.user # -U "PGHOST" = digitalocean_database_cluster.postgres.host # -h "PGPORT" = digitalocean_database_cluster.postgres.port # -p "PGDATABASE" = digitalocean_database_db.postgres.name # -d "PGSSLMODE" = "require" # -c sslmode=require "PGPASSWORD" = digitalocean_database_cluster.postgres.password } } }
I want to expose the connection string to my database as an output:
output "db_postgres_uri" { description = "Connection string for Postgres database cluster" value = digitalocean_database_cluster.postgres.uri sensitive = true }
I print it like this:
$ terraform output db_postgres_uri "postgresql://doadmin:THIS_IS_REDACTED_3NjMw@bee-db-cluster-postgres-do-user-12345678-0.l.db.ondigitalocean.com:25060/defaultdb?sslmode=require"
Notice that there's defaultdb in the output.
defaultdb
I want to have bee there, since this is the database I actually use.
bee
How can I accomplish this?
The text was updated successfully, but these errors were encountered:
As a workaround, could you set the value of your output to replace(digitalocean_database_cluster.postgres.uri, defaultdb, bee)
replace(digitalocean_database_cluster.postgres.uri, defaultdb, bee)
Sorry, something went wrong.
No branches or pull requests
Use case
I have a Postgres database in my infrastructure. It's defined like this:
I want to expose the connection string to my database as an output:
I print it like this:
The problem
Notice that there's
defaultdb
in the output.I want to have
bee
there, since this is the database I actually use.How can I accomplish this?
The text was updated successfully, but these errors were encountered: