Skip to content
Latchkey

Terraform Google Provider Credential Errors in CI

The google provider could not find Application Default Credentials. No service account key, no workload-identity token, and no gcloud auth are available to the runner.

What this error means

plan/apply fails with "could not find default credentials" from the google provider, or an error that the project is not set. It happens on a fresh runner without GCP auth configured.

terraform output
Error: Attempted to load application default credentials since neither
`credentials` nor `access_token` was set in the provider block. No credentials
loaded. To use your gcloud credentials, run 'gcloud auth application-default login'

Common causes

No Application Default Credentials

The runner has no GOOGLE_CREDENTIALS/GOOGLE_APPLICATION_CREDENTIALS, no workload-identity token, and no gcloud login, so ADC resolves to nothing.

Project not configured

Even with credentials, a missing project in the provider or GOOGLE_PROJECT env can fail operations that need an explicit project.

How to fix it

Authenticate via workload identity federation

Use keyless federation from GitHub OIDC to obtain short-lived GCP credentials.

.github/workflows/ci.yml
- uses: google-github-actions/auth@v2
  with:
    workload_identity_provider: projects/123/locations/global/workloadIdentityPools/ci/providers/gh
    service_account: ci-terraform@my-project.iam.gserviceaccount.com

Or provide a service account key

Set GOOGLE_CREDENTIALS from a secret and configure the project.

.github/workflows/ci.yml
env:
  GOOGLE_CREDENTIALS: ${{ secrets.GCP_SA_KEY }}
  GOOGLE_PROJECT:     my-project

How to prevent it

  • Use workload identity federation instead of static SA keys.
  • Set project/GOOGLE_PROJECT so operations have an explicit project.
  • Keep any SA key as a secret and rotate it.

Frequently asked questions

What causes "GCP credentials missing"?
The runner has no GOOGLE_CREDENTIALS/GOOGLE_APPLICATION_CREDENTIALS, no workload-identity token, and no gcloud login, so ADC resolves to nothing.
How do I fix GCP credentials missing?
Use keyless federation from GitHub OIDC to obtain short-lived GCP credentials.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card