terraform-contour-mirror/modules/pg-incluster/outputs.tf

31 lines
1.2 KiB
HCL

# Output shape byte-identical to modules/yc-database so k8s-secret consumes it
# unchanged. host = the database's own host or the module default (in-cluster svc).
output "databases" {
description = "Map of created databases (cluster_id:db_name:user_name => data)"
value = {
for key, db in local.databases_map : key => {
cluster_id = db.cluster_id
host = try(db.database.host, "") != "" ? db.database.host : var.default_host
port = var.default_port
database_name = postgresql_database.this[key].name
user_name = postgresql_role.this[key].name
password = random_password.user_password[key].result
}
}
sensitive = true
}
output "database_outputs_map" {
description = "Map for secrets module (cluster_id:db_name:user_name => credentials)"
value = {
for key, db in local.databases_map : key => {
host = try(db.database.host, "") != "" ? db.database.host : var.default_host
database_name = postgresql_database.this[key].name
user_name = postgresql_role.this[key].name
password = random_password.user_password[key].result
}
}
sensitive = true
}