Skip to content

Commit

Permalink
chore: create dbt dataset in US
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Jan 17, 2025
1 parent 196e78b commit b535308
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export DEV_ENV_NAME_PREFIX="${TF_VAR_name_prefix}"

export TARGET_BIGQUERY_CREDENTIALS_JSON="$(echo $TF_VAR_sa_creds | base64 -d)"
export TARGET_BIGQUERY_DATASET="${USER}_dataset"
export TARGET_BIGQUERY_LOCATION="EU"
export TARGET_BIGQUERY_LOCATION="US"
export DBT_BIGQUERY_DATASET="dataform_${USER}"
export DBT_BIGQUERY_KEYFILE="/lana/keyfile.json"
echo $TARGET_BIGQUERY_CREDENTIALS_JSON > meltano/keyfile.json
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@ services:
- TARGET_BIGQUERY_CREDENTIALS_JSON=${TARGET_BIGQUERY_CREDENTIALS_JSON}
- TARGET_BIGQUERY_DATASET=${TARGET_BIGQUERY_DATASET}
- TARGET_BIGQUERY_LOCATION=${TARGET_BIGQUERY_LOCATION}
- DBT_BIGQUERY_DATASET=${DBT_BIGQUERY_DATASET}
- DBT_BIGQUERY_KEYFILE=${DBT_BIGQUERY_KEYFILE}
23 changes: 23 additions & 0 deletions tf/bq-setup/bq.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,26 @@ resource "google_bigquery_dataset_iam_member" "dataform_assertions_additional_ow
role = "roles/bigquery.dataOwner"
member = "user:${each.value}"
}

resource "google_bigquery_dataset" "dbt" {
project = local.gcp_project
dataset_id = local.dbt_dataset_name
friendly_name = "${local.name_prefix} dbt"
description = "dbt for ${local.name_prefix}"
location = local.dbt_location
}

resource "google_bigquery_dataset_iam_member" "dbt_owner" {
project = local.gcp_project
dataset_id = google_bigquery_dataset.dbt.dataset_id
role = "roles/bigquery.dataOwner"
member = "serviceAccount:${google_service_account.bq_access_sa.email}"
}

resource "google_bigquery_dataset_iam_member" "dbt_additional_owners" {
for_each = toset(local.additional_owners)
project = local.gcp_project
dataset_id = google_bigquery_dataset.dbt.dataset_id
role = "roles/bigquery.dataOwner"
member = "user:${each.value}"
}
2 changes: 2 additions & 0 deletions tf/bq-setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ locals {
dataform_git_commitish = var.dataform_git_commitish != "" ? var.dataform_git_commitish : "${var.name_prefix}-dataform"


dbt_dataset_name = replace("dbt_${local.name_prefix}", "-", "_")
dbt_location = "US"
dataform_dataset_name = replace("dataform_${local.name_prefix}", "-", "_")
dataform_assertions_dataset_name = replace("dataform_assertions_${local.name_prefix}", "-", "_")
dataform_repo_name = "${local.name_prefix}-repo"
Expand Down

0 comments on commit b535308

Please sign in to comment.