Skip to content

Commit

Permalink
add db engine based conn string (#78)
Browse files Browse the repository at this point in the history
* add db engine based conn string

* fix db engine prefix
  • Loading branch information
pgvishnuram authored Aug 2, 2024
1 parent afb3b41 commit 895cfc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
13 changes: 13 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 895cfc6

Please sign in to comment.