Skip to content
Latchkey

Terraform Partial Backend "Error reading backend config file" in CI

Init was told to read partial backend settings from a *.tfbackend file, but the path is wrong or the file is not present on the runner - so the partial backend has no values.

What this error means

terraform init -backend-config=env/prod.tfbackend fails because the file cannot be read, or because the resulting backend is still missing required fields. It happens when the path is relative to the wrong directory or the file was not committed.

terraform init output
Error: Failed to read backend config file

Error reading "env/prod.tfbackend": open env/prod.tfbackend: no such file or
directory

Common causes

Wrong path to the .tfbackend file

The -backend-config path is relative to the working directory init runs in. A path that is correct locally can be wrong in CI if the job runs from a different directory.

Backend file not checked out or gitignored

If the *.tfbackend file is gitignored or generated by an earlier step that did not run, init cannot find it.

How to fix it

Use a correct, working-directory-relative path

Run init from the module directory and reference the backend file relative to it (or use an absolute path).

Terminal
cd infra/app
terraform init -input=false -backend-config=../env/prod.tfbackend

Ensure the file exists before init

  1. Confirm the *.tfbackend file is committed (not gitignored) or generated earlier in the job.
  2. If a previous step writes it, make init depend on that step.
  3. Verify the path resolves from init’s actual working directory.

How to prevent it

  • Commit per-environment *.tfbackend files alongside the module.
  • Reference them by a path relative to init’s working directory.
  • Run init with -input=false so missing values fail fast.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →