How it works
The explanation, with examples you can run.
What is the same
- The language: HCL configurations written for Terraform 1.5 work in OpenTofu, and most later configurations that avoid tool-specific features work in both.
- Providers: both use the same provider plugin protocol. Most providers are published to both the Terraform Registry and the OpenTofu Registry (
registry.opentofu.org). - State: OpenTofu works with state files written by Terraform up to 1.5.x; for state from later Terraform releases, follow the migration guide and verify with a plan.
- Workflow:
tofu init,tofu plan,tofu apply, the same asterraform.
What has diverged
Each project now ships features the other lacks. A few examples, not a complete list:
| OpenTofu | Terraform |
|---|---|
| Client-side state and plan encryption (1.7) | Ephemeral resources (1.10) and write-only arguments (1.11) |
| Early evaluation: variables in backend and module source blocks (1.8) | Stacks and deeper HCP Terraform integration |
for_each on provider configurations (1.9), -exclude flag | Query (list) blocks for discovering existing resources to import |
| OCI registries for providers and modules (1.10) |
Feature sets change with every release, so check the current documentation for anything you depend on. Configuration that uses features of one tool will not run on the other.
Choosing, neutrally
Questions worth answering for your team:
- Licence: does the BSL affect you? For most companies managing their own infrastructure, HashiCorp's terms permit that use; vendors building products around Terraform are the main group restricted. Some organisations require OSI-approved licences for all tooling, which only OpenTofu meets.
- Platform: HCP Terraform and Terraform Enterprise run Terraform. Other platforms (Spacelift, env0, Scalr, Harness, self-hosted CI) commonly support both.
- Features you need from either column above.
- Support and governance: a single vendor's roadmap and commercial support, or a foundation-governed project with several backing companies.
Switching
The OpenTofu migration guide describes a safe, reversible process: back up your state and code, install OpenTofu, initialise and verify the configuration (tofu init fetches providers from the OpenTofu Registry, and tofu plan should show no changes), then test with a small change before relying on it. Configurations that share data through terraform_remote_state need extra care, covered in a separate guide. Switching back is possible as long as you have not used OpenTofu-only features such as state encryption. Do it one state at a time, not across the whole estate at once.
Note: the examples in this path were run with Terraform, not OpenTofu (it was not installed); they use only features the two share, except where a version note says otherwise.
Check yourself
3 questions. Get them all right to finish this topic.
0 of 3 right so far. Get all three to finish this topic.