build and use local map of username to dbname
This commit is contained in:
parent
d361fa8da9
commit
010ac595c1
1 changed files with 10 additions and 2 deletions
|
|
@ -3,6 +3,14 @@ output "postgres_instance_id" {
|
|||
value = stackit_postgresflex_instance.this.instance_id
|
||||
}
|
||||
|
||||
locals {
|
||||
# Build a map: username => db_name
|
||||
user_to_db = {
|
||||
for db in var.postgres_databases :
|
||||
db.user_name => db.db_name
|
||||
}
|
||||
}
|
||||
|
||||
# Postgres Credential Output
|
||||
output "postgres_credentials" {
|
||||
value = {
|
||||
|
|
@ -12,7 +20,7 @@ output "postgres_credentials" {
|
|||
username = u.username
|
||||
password = u.password
|
||||
port = u.port
|
||||
db_name = stackit_postgresflex_database.this[u.username].name
|
||||
db_name = stackit_postgresflex_database.this[local.user_to_db[u.username]].name
|
||||
uri = u.uri
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue