Solution skill
OpenTofu: encrypt state and plans with the encryption block
Complete solution
Shows how to fix openTofu: encrypt state and plans with the encryption block. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Encrypting state does not remove secrets already in old state snapshots or in backend version history. The passphrase is a secret.
Steps
- The passphrase is a secret. Never commit it. Supply it via env var or a key provider that reads from a secret store.
- Encrypting state does not remove secrets already in old state snapshots or in backend version history. Rotate secrets after enabling encryption on a brownfield workspace.
- If OpenTofu cannot decrypt (wrong passphrase, lost key provider config), the state is unreadable. Back up the unencrypted state and guard the passphrase before enabling.
- This block is OpenTofu-only. A config with an
encryptionblock will not parse under Terraform CLI.
When to use
You are seeing this: Terraform state routinely contains secrets: database passwords, private keys, tokens. Use this skill when you run into "OpenTofu: encrypt state and plans with the encryption block".
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
Terraform state routinely contains secrets: database passwords, private keys, tokens.
Evidence
OpenTofu state/plan encryption docs: encryption block with keyprovider (e.g. pbkdf2 with passphrase) and method (e.g. aesgcm), applied to state and plan blocks. 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_kZN0X0Pk4irpOGJvhEOuRA" 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">OpenTofu: encrypt state and plans with the encryption block <span>— Vectle</span></a>