From 8e58f1b09705cad5188ec23aa690a5c900282134 Mon Sep 17 00:00:00 2001 From: Sandipan Date: Mon, 3 Jun 2024 17:19:28 +0530 Subject: [PATCH] chore: bq connection locations configurable (#185) * chore: bq connection locations configurable * fix: fmt --- modules/postgresql/gcp/database/main.tf | 3 ++- modules/postgresql/gcp/main.tf | 17 ++++++++------- modules/postgresql/gcp/variables.tf | 28 ++++++++++++++----------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/modules/postgresql/gcp/database/main.tf b/modules/postgresql/gcp/database/main.tf index e8a098f8..d87fa9f1 100644 --- a/modules/postgresql/gcp/database/main.tf +++ b/modules/postgresql/gcp/database/main.tf @@ -8,6 +8,7 @@ variable "replication" {} variable "connection_users" { type = list(string) } +variable "big_query_connection_location" {} output "user" { value = postgresql_role.user.name @@ -138,7 +139,7 @@ resource "google_bigquery_connection" "db" { project = var.gcp_project friendly_name = "${var.db_name}-connection" description = "Connection to ${var.db_name} database" - location = "US" + location = var.big_query_connection_location cloud_sql { instance_id = var.pg_instance_connection_name diff --git a/modules/postgresql/gcp/main.tf b/modules/postgresql/gcp/main.tf index 6ee9ced4..4276d703 100644 --- a/modules/postgresql/gcp/main.tf +++ b/modules/postgresql/gcp/main.tf @@ -85,14 +85,15 @@ module "database" { for_each = toset(local.databases) source = "./database" - gcp_project = local.gcp_project - db_name = each.value - admin_user_name = google_sql_user.admin.name - user_name = "${each.value}-user" - user_can_create_db = var.user_can_create_db - pg_instance_connection_name = google_sql_database_instance.instance.connection_name - connection_users = local.big_query_viewers - replication = local.replication + gcp_project = local.gcp_project + db_name = each.value + admin_user_name = google_sql_user.admin.name + user_name = "${each.value}-user" + user_can_create_db = var.user_can_create_db + pg_instance_connection_name = google_sql_database_instance.instance.connection_name + connection_users = local.big_query_viewers + replication = local.replication + big_query_connection_location = local.big_query_connection_location } provider "postgresql" { diff --git a/modules/postgresql/gcp/variables.tf b/modules/postgresql/gcp/variables.tf index 65dfba88..7eda30cf 100644 --- a/modules/postgresql/gcp/variables.tf +++ b/modules/postgresql/gcp/variables.tf @@ -39,18 +39,22 @@ variable "provision_read_replica" { type = bool default = false } +variable "big_query_connection_location" { + default = "US" +} locals { - gcp_project = var.gcp_project - vpc_name = var.vpc_name - region = var.region - instance_name = var.instance_name - destroyable = var.destroyable - highly_available = var.highly_available - tier = var.tier - max_connections = var.max_connections - databases = var.databases - big_query_viewers = var.big_query_viewers - replication = var.replication - provision_read_replica = var.provision_read_replica + gcp_project = var.gcp_project + vpc_name = var.vpc_name + region = var.region + instance_name = var.instance_name + destroyable = var.destroyable + highly_available = var.highly_available + tier = var.tier + max_connections = var.max_connections + databases = var.databases + big_query_viewers = var.big_query_viewers + replication = var.replication + provision_read_replica = var.provision_read_replica + big_query_connection_location = var.big_query_connection_location }