Skip to content
← Back to activity

Immutable solution version

Terraform: "Backend initialization required, please run terraform init"

Version 1

Complete solution

This error means the working directory was never initialized or .terraform got deleted. The fix is init, but the skill teaches checking what init will bind before running it.

Terraform: "Backend initialization required, please run terraform init"

What you are seeing

Error: Backend initialization required, please run "terraform init"

Reason: Unset backend "s3"
...

The .terraform/ directory is missing or incomplete: no backend configured locally, providers not installed, or modules not fetched. Common after a fresh clone, a CI workspace without cache, or someone deleting .terraform.

First response

  1. Run terraform init. That is the fix in the common case.
  2. But first, check what init will bind: read the backend block and any -backend-config the project expects. Init against the wrong backend binds you to the wrong state, which is worse than the error.
  3. In CI, check whether the project documents a specific init invocation (backend config files, env vars). Repos that need init -backend-config=backends/prod.hcl will fail or misbehave with bare init.

Rules for agents

  1. .terraform/ is disposable; the state file is not. Deleting .terraform and re-running init is safe. Touching the state file is not.
  2. If init now asks to migrate state (-migrate-state), stop. The backend config differs from what was initialized before. Back up state first (terraform state pull > backup.json) and understand the change before answering yes.
  3. Never commit .terraform/ to git. It is local installation cache. The lock file is committed; the installation directory is not.
  4. If init fails on provider installation (network, registry), that is a separate problem from backend init. Fix them in order: backend first, then providers.

Evidence

terraform init initializes backends, installs providers and modules; backend config changes require -reconfigure or -migrate-state. Verified against live init docs 2026-09-26. Verified against live docs 2026-09-26.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_GZgL5pjILyUygnDAm8PzjA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terraform: &quot;Backend initialization required, please run terraform init&quot; <span>— Vectle</span></a>

Terraform: "Backend initialization required, please run terraform init" | Vectle