Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Terraform vs OpenTofu: what are the practical differences?

11 min read
Improve this page

Logo Terraform

Terraform or OpenTofu: which one should you choose for your project? For most DevOps uses, the two are compatible and produce the same infrastructure. The most visible difference is the license. This guide presents the context of the fork (OpenTofu is a version derived from Terraform's code, maintained separately), the concrete differences, and a recommendation depending on your situation: company, training or personal lab.

Quick guidelines:

  • Personal lab, training: Terraform, or OpenTofu if you care about an open source license
  • Company that depends on the HashiCorp ecosystem (HCP, Vault, Consul): Terraform
  • SaaS product built on IaC: OpenTofu (MPL-2.0 license, no commercial restriction)

What you will learn

  • The context of the fork: why OpenTofu exists
  • The concrete differences: license, governance, a few features specific to each tool
  • Which recommendation: Terraform or OpenTofu depending on your context
  • Migrating without rewriting: replacing terraform with tofu in your commands

Context: the license change

In August 2023, HashiCorp moved Terraform from the MPL-2.0 open source license to the BSL 1.1 (Business Source License), starting with version 1.6. HashiCorp justified the change by the need to protect its commercial investments against cloud providers that offered Terraform as a Service without contributing back.

The BSL restricts the uses considered "competitive offerings":

  • Offering a product or service that competes with HashiCorp's commercial offerings (HCP Terraform, Terraform Cloud).
  • Using Terraform to build a managed service that competes with HashiCorp, without a commercial agreement.

HashiCorp states that internal use within an organization is not considered a competitive offering.

For most DevOps uses (CI/CD, automation, labs), the BSL changes nothing in practice. For companies that redistribute tools built on Terraform, it is a real constraint.

OpenTofu was created to guarantee an alternative under the MPL-2.0 license (Mozilla Public License 2.0), recognized as open source by the OSI.

Side-by-side comparison

The table compares the two tools on the criteria that matter in a real choice. The two projects mostly differ by license and governance; the rest is a matter of compatibility, with the feature gaps detailed further down.

CriterionTerraformOpenTofu
LicenseBSL 1.1 (not recognized as open source by the OSI)MPL-2.0 (open source)
MaintainerHashiCorp, an IBM subsidiary since February 2025Community, project hosted by the Linux Foundation (CNCF, sandbox stage)
OriginOriginal productFork of the open source 1.5.x line, its own branch since 1.6
HCL compatibilityReferenceVery high (aims to be a drop-in replacement, without changing the code)
State formatReferenceCompatible
ProvidersHashiCorp RegistryCompatible; own registry at registry.opentofu.org
CLIterraformtofu
PriceFree (CLI)Free

Compatibility: migrating without rewriting

For most projects, switching from Terraform to OpenTofu comes down to:

Terminal window
# Replace terraform with tofu in every call
tofu init
tofu plan
tofu apply

The .tf files generally do not change. The state format is compatible. The usual providers of the Terraform Registry work with OpenTofu. Read the migration guide for the special cases, or the lesson Migrating from Terraform (in French) in the OpenTofu module.

One difference does appear on the very first tofu init. The lock file .terraform.lock.hcl written by Terraform points to the HashiCorp registry; tofu init rewrites it with the OpenTofu one, for the same version (tested on Debian 13, Terraform 1.17.2, OpenTofu 1.13.11, libvirt provider 0.9.9):

# before tofu init, written by Terraform
provider "registry.terraform.io/dmacvicar/libvirt" {
version = "0.9.9"
constraints = "~> 0.9.0"
# after tofu init
provider "registry.opentofu.org/dmacvicar/libvirt" {
version = "0.9.9"
constraints = "~> 0.9.0"

The version and the constraint are identical; only the registry address changes. This file is committed: if a team mixes the two tools on the same repository, it may change when switching from one to the other.

The points of divergence

The two projects diverge on a few advanced features, in both directions: each has functions that the other lacks. The lessons of the OpenTofu (in French) module detail each gap; here are the main ones.

State encryption (OpenTofu 1.7)

OpenTofu added native encryption of the state and of plans. Terraform has no such built-in feature. The full implementation is in the lesson Encrypting the state and plans (in French).

# opentofu only
terraform {
encryption {
key_provider "pbkdf2" "my_passphrase" {
passphrase = var.state_passphrase
}
method "aes_gcm" "my_method" {
keys = key_provider.pbkdf2.my_passphrase
}
state {
method = method.aes_gcm.my_method
}
}
}

Variables in the backend and in modules (OpenTofu 1.8)

OpenTofu accepts variables and locals in the backend block (which says where the state is stored) and in a module's source and version, from tofu init on. Terraform refuses variables in a backend; it only allows them in source and version since 1.15, for a variable declared const = true. The lesson Variables in backend and modules (in French) details the rule.

Taking a resource out of the configuration: the removed block

A removed block without lifecycle does not behave the same way: OpenTofu forgets the object, which stays in place in the infrastructure, whereas Terraform destroys it. The same code can therefore delete a resource on one side and not on the other: always write lifecycle { destroy = ... }, as explained in the lesson Refactor, import and removed (in French).

Version constraint (OpenTofu 1.12)

Since 1.12, OpenTofu no longer reads required_version (the constraint that limits which versions of the tool are allowed) in a .tf file: it only reads it in a .tofu file. Terraform, for its part, applies the constraint written in a .tf. The lesson Migrating from Terraform (in French) gives the consequences.

This behavior was tested on Debian 13 with OpenTofu 1.13.11 and Terraform 1.17.2, without a test on 1.12 itself. A >= 99.0.0 constraint written in a .tf is ignored by OpenTofu (the plan succeeds). The same constraint in a .tofu makes the plan fail, and Terraform applies it in a .tf.

What Terraform has that OpenTofu lacks: actions and terraform query

Terraform added two features in 1.14. Actions (the action block) run a one-off operation of a provider, which is not an object to create or destroy. The terraform query command searches a provider for resources that already exist, to attach them to the configuration. OpenTofu has no equivalent in its versions up to 1.13.

Provider functions and tests: little difference

A provider can expose its own HCL functions. Terraform 1.8 (April 10, 2024) introduced this feature, and OpenTofu 1.7 (April 30, 2024) followed twenty days later. Both tools use the same syntax: provider::<provider_name>::<function_name>().

terraform test and tofu test are equivalent for common cases, but their versions evolve independently.

How do you choose?

Choose Terraform if:

  • Your organization depends on the HashiCorp commercial ecosystem (HCP Terraform, Vault, Consul, Nomad).
  • You need official HashiCorp / IBM support.
  • Your team already works with HashiCorp products.

Choose OpenTofu if:

  • An open source license (MPL-2.0, recognized by the OSI) is an important criterion.
  • You do not depend on HashiCorp's commercial products.
  • You want native state encryption.
  • Your organization prefers community governance (Linux Foundation).

Both work if:

  • You use common providers (libvirt, Kubernetes, AWS, GCP, Azure).
  • You do not offer Terraform as a Service.
  • You just want to automate your infrastructure.

In all these cases, still check compatibility on your actual versions before switching.

On this site

If you chose OpenTofu, the OpenTofu (in French) module of the training covers what really changes: migrating a Terraform repository, native encryption of the state and plans, variables resolved from tofu init, registry and OCI sources, refactor blocks. You follow it after the advanced level.

Put it into practice

This lab checks the claim "the two tools are compatible". You make a configuration portable by declaring the source and the version constraint of each provider, then you observe, on the structured state (the state in JSON format), that the two binaries read the same state and resolve the same versions on two different registries. The validation focuses on the point where portability stops: the lock file. Its last three checks run tofu: install it before running them. Step 3 of the lesson Migrating from Terraform (in French) explains the installation.

Key points

  • Terraform's BSL 1.1 restricts "competitive offerings"; for internal use and most companies, nothing changes.
  • OpenTofu is a compatible fork, hosted by the Linux Foundation (CNCF project at the sandbox stage) under the MPL-2.0 license (open source, recognized by the OSI).
  • The .tf files, the state format and the usual providers are compatible between the two tools.
  • The two tools diverge on a few points, in both directions: OpenTofu has native state encryption and variables in the backend, Terraform has actions (one-off operations of a provider) and terraform query (search for existing resources).
  • A removed block without lifecycle gives a different result: OpenTofu forgets the resource, Terraform destroys it. A required_version written in a .tf is ignored by OpenTofu.
  • The choice depends mostly on the license and governance you want, not on everyday features.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer