diff --git a/terraform/outputs.tf b/terraform/outputs.tf index d5f76bd..454e0e5 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -19,7 +19,7 @@ output "bastion_proxy_command" { } output "db_connection_string" { - value = var.deploy_db ? "postgres://${element(concat(tolist(google_sql_user.airflow.*.name)), 0)}:${local.postgres_airflow_password}@${element(concat(tolist(google_sql_database_instance.instance.*.private_ip_address)), 0)}:5432" : "N/A: DB is not deployed with the terraform-google-astronomer-gcp module. Set deploy_db = true" + value = var.deploy_db ? "${local.db_engine == "mysql" ? "mysql://" : "postgres://"}${element(concat(tolist(google_sql_user.airflow.*.name)), 0)}:${local.postgres_airflow_password}@${element(concat(tolist(google_sql_database_instance.instance.*.private_ip_address)), 0)}:${var.database_ports[local.db_engine].port}" : "N/A: DB is not deployed with the terraform-google-astronomer-gcp module. Set deploy_db = true" sensitive = true } diff --git a/terraform/variables.tf b/terraform/variables.tf index faf9db6..ab67c46 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -136,6 +136,19 @@ variable "db_version" { description = "define postgres database version" } +variable "database_ports" { + type = map(any) + default = { + "mysql" = { + port = 3306 + } + "postgres" = { + port = 5432 + } + } + description = "Optional configuration to define postgres db version" +} + variable "db_deletion_protection" { type = bool default = true