question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use default google cloud project if not supplied?

See original GitHub issue

Describe the feature

Currently using BigQuery requires defining your project in profiles.yml: https://docs.getdbt.com/reference/warehouse-profiles/bigquery-profile/

Google Cloud APIs generally fall back to the default project when one isn’t specified. This is helpful for code that runs in multiple project environments — it’ll reference the datasets in whatever project it’s running in.

So the feature would be to align dbt with that standard, and allow for:

my-bigquery-db:
  target: dev
  outputs:
    dev:
      type: bigquery
      method: oauth
      # project: [GCP project id] <- uses the current project
      dataset: [the name of your dbt dataset] # You can also use "schema" here
      threads: [1 or more]
      timeout_seconds: 300
      location: US # Optional, one of US or EU
      priority: interactive
      retries: 1

Describe alternatives you’ve considered

Currently we have something like:

nimbus:
  target: main
  outputs:
    user: main:
      type: bigquery
      method: oauth
      project: "{{ env_var('PROJECT', 'project_foo') }}"

…and set $PROJECT to the result of gcloud config get-value project. This is OK, but some cruft.

(and if I’m missing something and there’s any easy solution to this, that would be gratefully received!)

Who will this benefit?

BigQuery users, particularly those running across dev and prod environments

Are you interested in contributing this feature?

Not right now, given my other OSS work, but would be keen to contribute to dbt at some point!

Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jtcohen6commented, Oct 12, 2020

Thanks for the detailed proposal, @max-sixty. I think it makes sense to fall back to the default project configured by the gcloud user / service account if it’s not specified in profiles.yml.

This isn’t a change we would prioritize, and I’m glad to see you have a workaround in the meantime. I imagine it could be quite straightforward. I’ll mark this a good first issue, for whenever you (or another community member) has the time.

0reactions
yu-iskwcommented, Jan 29, 2021

There are two approaches to set scopes to the oauth method, if there is no way to grant scopes to a google cloud account.

  1. Pass the SCOPE constant to google.auth.default for the oauth method too.
  2. Add a sub map to pass scopes to profiles.yml like below.
my-bigquery-db:
  target: dev
  outputs:
    dev:
      type: bigquery
      method: oauth
      project: [GCP project id]
      dataset: [the name of your dbt dataset] # You can also use "schema" here
      threads: [1 or more]
      timeout_seconds: 300
      location: US # Optional, one of US or EU
      priority: interactive
      retries: 1
      scopes:
        - https://www.googleapis.com/auth/bigquery
        - https://www.googleapis.com/auth/cloud-platform
        - https://www.googleapis.com/auth/drive
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use default google cloud project if not supplied? #2828 - GitHub
Google Cloud APIs generally fall back to the default project when one isn't specified. This is helpful for code that runs in multiple ......
Read more >
Set defaults for gcloud commands | Artifact Registry ...
You can set a default project, repository, and repository location in the Google Cloud CLI active configuration so that you do not need...
Read more >
Google Cloud projects | Apps Script
By default, Cloud projects have an Identity and Access Management (IAM) policy with one entry, a Google service account that acts as the...
Read more >
How to change the project in GCP using CLI commands
Change to the project's account if not: gcloud config set account `ACCOUNT`. Depending on the account, the project list will be different:
Read more >
How to meet Google Cloud Platform security best practices
By default, VM disks are encrypted with Google-managed keys. They are not encrypted with Customer-Supplied Encryption Keys. Currently, there is no way to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found