Migrate an existing Terraform codebase and state to OpenTofu
domain: opentofu.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Install the tofu CLI alongside (or in place of) terraform on developer machines and CI runners.
Run tofu init -upgrade in each root module so OpenTofu resolves providers and modules through its own registry/lockfile instead of reusing cached Terraform-registry data.
Run tofu plan and confirm it reports no changes against the existing state, since OpenTofu reads and writes the same state file format as Terraform without conversion.
Update CI/CD pipeline scripts, Makefiles, and pre-commit hooks to invoke tofu instead of terraform for plan/apply/fmt/validate steps.
Roll out to non-production workspaces first, keep the ability to fall back to terraform for a period, then migrate production once the non-prod run has been validated.
Known gotchas
State needs no conversion — OpenTofu and Terraform share the same JSON state format — but a dirty or drifted state should be reconciled first so tofu plan's no-op check is meaningful.
-upgrade is needed on the first tofu init or it may reuse Terraform-registry-sourced provider/module caches instead of resolving through OpenTofu's own registry.
OpenTofu's backward-compatibility guarantee covers Terraform configuration syntax up to a specific past Terraform version — newer Terraform-only language features adopted later may not be supported, so verify recently adopted HCL features still work.
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?