Example Terraform configuration for testing PostgreSQL integration: - main.tf: VPC and database setup - postgres.tf: Database resource definitions - outputs.tf: Output values for connection - test_basic.sh: Basic connectivity tests - test_lifecycle.sh: Full lifecycle testing - terraform.tfvars.example: Configuration template - .gitignore: Ignore sensitive data and terraform artifacts
43 lines
1.6 KiB
HCL
43 lines
1.6 KiB
HCL
// 2026-04-01 — outputs.tf: данные подключения к PostgreSQL после apply.
|
|
//
|
|
// Пароль не выводим напрямую — только через sensitive output (не появляется
|
|
// в логах CI по умолчанию). Для явного показа: terraform output pg_password
|
|
|
|
output "pg_instance_id" {
|
|
description = "ID инстанса PostgreSQL в Nubes"
|
|
value = nubes_postgres.pg_test_instance.id
|
|
}
|
|
|
|
output "pg_host" {
|
|
description = "Внутренний адрес master-ноды PostgreSQL"
|
|
value = local.pg_host
|
|
}
|
|
|
|
output "pg_port" {
|
|
description = "Порт PostgreSQL"
|
|
value = local.pg_port
|
|
}
|
|
|
|
output "pg_database" {
|
|
description = "Имя базы данных"
|
|
value = nubes_postgres_database.pg_test_db.db_name
|
|
}
|
|
|
|
output "pg_username" {
|
|
description = "Имя пользователя PostgreSQL"
|
|
value = nubes_postgres_user.pg_test_user.username
|
|
}
|
|
|
|
output "pg_password" {
|
|
description = "Пароль пользователя из vault_secrets (пустой на первом apply — заполнится на следующем)"
|
|
value = local.pg_password
|
|
sensitive = true
|
|
}
|
|
|
|
// Удобная строка подключения — для psql или приложений.
|
|
output "pg_dsn" {
|
|
description = "DSN для подключения: postgresql://user:pass@host:port/db"
|
|
value = "postgresql://${nubes_postgres_user.pg_test_user.username}:${local.pg_password}@${local.pg_host}:${local.pg_port}/${nubes_postgres_database.pg_test_db.db_name}"
|
|
sensitive = true
|
|
}
|