Terraform "Backend initialization required, please run terraform init"
Terraform stores backend setup under .terraform/, which is not committed. A CI job that runs plan/apply without an earlier init in the same workspace has no backend configured.
What this error means
terraform plan or terraform apply refuses to run and says backend initialization is required, often after a terraform init step was skipped, cached incorrectly, or run in a different directory.
terraform
Error: Backend initialization required, please run "terraform init"
Reason: Initial configuration of the requested backend "s3"
The "backend" is the interface that Terraform uses to store state and
perform operations.Common causes
init never ran in this job
The pipeline jumped straight to plan/apply, or ran init in a different working directory than the one plan uses.
.terraform was not persisted
init ran in an earlier job whose .terraform/ directory was not cached or passed to the plan job.
Backend block was added or changed
A new or modified backend block requires a fresh init before any operation.
How to fix it
Run init in the same directory before plan
Terminal
terraform -chdir=infra init -input=false
terraform -chdir=infra plan -input=falsePersist .terraform across jobs
- If init and plan are separate jobs, cache or upload the
.terraform/directory and the lock file. - Restore them in the plan/apply job before running.
- Prefer running init+plan in one job to avoid the handoff entirely.
How to prevent it
- Make
terraform initthe first step of every Terraform job. - Use
-chdirconsistently so all steps target the same module directory. - Re-init whenever the
backendblock changes.
Related guides
Terraform "Required token could not be found" - backend auth in CIFix Terraform "required token could not be found" during init in CI - the remote backend or private registry…
Terraform "Failed to get existing workspaces" - S3 backend in CIFix Terraform init "Failed to get existing workspaces" with an S3 backend in CI - the runner cannot list the…
Terraform "Error acquiring the state lock" - DynamoDB at init in CIFix Terraform "Error acquiring the state lock" against a DynamoDB lock table in CI - a missing table, missing…