Skip to content

Use artifacts from GCS

dbt-tools can read manifest.json and related artifacts directly from a Google Cloud Storage bucket. This is common when dbt runs in Dataproc, Cloud Composer, or other GCP-hosted pipelines that upload artifacts to GCS after a run.

Minimal example

bash
export DBT_TOOLS_GCS_PROJECT_ID=my-gcp-project
npx @dbt-tools/cli status \
  --dbt-target gs://my-bucket/dbt/prod/latest \
  --json

Required objects

The GCS prefix must contain:

Object key (relative to prefix)Required
manifest.jsonYes
run_results.jsonYes (for run-related commands)
catalog.jsonNo
sources.jsonNo

For example, if --dbt-target is gs://my-bucket/dbt/prod/latest, dbt-tools reads:

text
gs://my-bucket/dbt/prod/latest/manifest.json
gs://my-bucket/dbt/prod/latest/run_results.json

Environment variables

VariableRequiredDescription
DBT_TOOLS_GCS_PROJECT_IDYesGCP project ID used for billing and quota
DBT_TOOLS_GCS_IMPERSONATE_SERVICE_ACCOUNTNoService account email to impersonate

Standard GCP credential variables also apply: GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PROJECT. dbt-tools inherits the standard Google Cloud SDK credential chain (Application Default Credentials).

With service account impersonation

Use impersonation to avoid embedding service account key files. The caller must have the roles/iam.serviceAccountTokenCreator role on the target service account:

bash
export DBT_TOOLS_GCS_PROJECT_ID=my-gcp-project
export DBT_TOOLS_GCS_IMPERSONATE_SERVICE_ACCOUNT=dbt-artifact-reader@my-project.iam.gserviceaccount.com
npx @dbt-tools/cli status \
  --dbt-target gs://my-bucket/dbt/prod/latest \
  --json

With a service account key file

bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
export DBT_TOOLS_GCS_PROJECT_ID=my-gcp-project
npx @dbt-tools/cli status \
  --dbt-target gs://my-bucket/dbt/prod/latest \
  --json

Prefer Workload Identity or impersonation over key files in production.

Grant the service account or user read-only access to the artifact prefix:

text
roles/storage.objectViewer

Scoped to the specific bucket or with a condition on the object prefix. Do not grant write permissions. dbt-tools only reads artifacts.

Using in GitHub Actions with Workload Identity

yaml
- uses: google-github-actions/auth@v2
  with:
    workload_identity_provider: projects/123456/locations/global/workloadIdentityPools/my-pool/providers/my-provider
    service_account: dbt-artifact-reader@my-project.iam.gserviceaccount.com

- name: Check dbt artifact health from GCS
  env:
    DBT_TOOLS_GCS_PROJECT_ID: my-gcp-project
  run: |
    npx @dbt-tools/cli status \
      --dbt-target gs://my-bucket/dbt/prod/latest \
      --json

Troubleshooting

SymptomLikely causeFix
Object not foundObject does not exist at the prefixConfirm the prefix contains manifest.json
403 ForbiddenIAM policy missing storage.objects.getGrant roles/storage.objectViewer to the caller
Invalid projectDBT_TOOLS_GCS_PROJECT_ID not setExport the variable before running the command
Impersonation failsCaller lacks roles/iam.serviceAccountTokenCreatorGrant the token creator role on the target service account

Released under the repository license terms.