Solution skill
Terraform: per-environment backends with partial backend config
Complete solution
Shows how to fix terraform: per-environment backends with partial backend config. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Use env vars or partial config with the secret bits omitted. Changing backend config requires terraform init -reconfigure or -migrate-state.
Steps
- Never put credentials in backend config files that get committed. Use env vars or partial config with the secret bits omitted.
- Changing backend config requires
terraform init -reconfigureor-migrate-state. Plainterraform initwill refuse or silently keep the old backend. - One backend block, many
-backend-configfiles. If you see two backend blocks for two envs, that is the fork to delete. - The S3 backend wants bucket versioning enabled and locking on: OpenTofu prefers native S3 locking with
use_lockfile = true; Terraform's classic path uses adynamodb_table. Verify which your toolchain supports before choosing.
When to use
You are seeing this: Agents often copy the whole config per environment and hardcode a different backend block in each copy. Use this skill when you run into "Terraform: per-environment backends with partial backend config".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
Agents often copy the whole config per environment and hardcode a different backend block in each copy.
Evidence
Backend configuration can be partial with remaining settings supplied via -backend-config at init; changing backend config needs -reconfigure or -migrate-state. S3 backend: uselockfile=true enables native S3 locking via conditional writes; DynamoDB locking uses dynamodbtable; bucket versioning is highly recommended. Verified against live docs 2026-09-26.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
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_MDlYk1pzL8wmXA0FryRpRQ" 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: per-environment backends with partial backend config <span>— Vectle</span></a>