Skip to content

Commit

Permalink
chore: bq connection locations configurable (#185)
Browse files Browse the repository at this point in the history
* chore: bq connection locations configurable

* fix: fmt
  • Loading branch information
sandipndev authored Jun 3, 2024
1 parent ad44d04 commit 8e58f1b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
3 changes: 2 additions & 1 deletion modules/postgresql/gcp/database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ variable "replication" {}
variable "connection_users" {
type = list(string)
}
variable "big_query_connection_location" {}

output "user" {
value = postgresql_role.user.name
Expand Down Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions modules/postgresql/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
28 changes: 16 additions & 12 deletions modules/postgresql/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 8e58f1b

Please sign in to comment.