Andrew Mercer
on this page

What it is

OpenTofu is a fork of Terraform 1.5.x, created after HashiCorp moved Terraform from the MPL 2.0 to the Business Source License (BSL 1.1) in August 2023. It's governed by the Linux Foundation and was accepted into the CNCF as a Sandbox project in April 2025. The CLI is tofu; the language, providers and state format started out identical to Terraform's.

Terraform OpenTofu
Licence BSL 1.1 (source-available) MPL 2.0 (open source)
Steward HashiCorp (an IBM company since early 2025) Linux Foundation / CNCF
Current line (Nov 2026) 1.16 1.12
Registry registry.terraform.io registry.opentofu.org (mirrors most providers/modules)
Managed platform HCP Terraform / Terraform Enterprise Third parties: Spacelift, env0, Scalr, Harness, others

For most day-to-day use (resources, modules, state, the workflow), they're interchangeable. The differences are at the edges, and they're growing in both directions.

Feature divergence

OpenTofu-only (or OpenTofu-first)

Version Feature
1.7 Client-side state and plan encryption; provider-defined functions (before Terraform's 1.8); removed blocks; import with for_each
1.8 Early variable evaluation: variables and locals in backend blocks and module source/version; .tofu file extension for OpenTofu-specific overrides
1.9 for_each on provider blocks; -exclude flag (inverse of -target)
1.10 OCI registries for providers and modules; S3-native locking; experimental external key providers and methods for encryption
1.11 Ephemeral resources and write-only arguments; enabled meta-argument; module variable/output deprecation
1.12 Dynamic prevent_destroy (can reference variables in the same module); destroy lifecycle setting; -json-into=FILE; provider checksums populated for all platforms on init; WinRM provisioner connections deprecated

Terraform-only

  • HCP Terraform integration: cloud block, Stacks, Sentinel/OPA/tfpolicy policy sets, no-code modules, health assessments
  • Actions and list resources / terraform query (1.14+)
  • import blocks inside child modules (1.16)
  • Terraform 1.12+ short-circuit &&/|| (check OpenTofu's docs for your version)
  • Some HashiCorp partner integrations

Both have since added equivalents of several of each other's features (variables in module sources reached Terraform in 1.15, years after OpenTofu 1.8). Check each project's docs for the version you run before assuming parity.

State encryption

The OpenTofu feature with no Terraform equivalent. State and plan files are encrypted client-side before reaching the backend, so a leaked storage container or plan artifact yields ciphertext.

terraform {
  encryption {
    key_provider "pbkdf2" "main" {
      passphrase = var.state_passphrase      # early evaluation: variables allowed here
    }

    # Or a KMS: key_provider "aws_kms" / "gcp_kms" / "openbao",
    # or the experimental "external" provider (1.10+) to call your own program,
    # e.g. one that wraps Azure Key Vault. Check its status for your version.

    method "aes_gcm" "main" {
      keys = key_provider.pbkdf2.main
    }

    state {
      method   = method.aes_gcm.main
      enforced = true                        # refuse to write unencrypted state
    }

    plan {
      method   = method.aes_gcm.main
      enforced = true
    }
  }
}

variable "state_passphrase" {
  type      = string
  sensitive = true
}

Migrating an existing unencrypted state:

terraform {
  encryption {
    key_provider "pbkdf2" "main" { passphrase = var.state_passphrase }
    method "aes_gcm" "main" { keys = key_provider.pbkdf2.main }
    method "unencrypted" "migrate" {}

    state {
      method = method.aes_gcm.main
      fallback {
        method = method.unencrypted.migrate   # can still read the old plaintext state
      }
    }
  }
}

Apply once (state is rewritten encrypted), then remove the fallback and set enforced = true.

Cautions:

  • Losing the key loses the state. Back up the key material separately from the state, and test a restore.
  • Once encrypted, the state is unreadable by Terraform, by terraform_remote_state consumers without the key, and by tools that parse state directly (some Terragrunt optimisations, drift tools).

Early variable evaluation

# OpenTofu 1.8+
variable "env" { type = string }

terraform {
  backend "azurerm" {
    resource_group_name  = "rg-tfstate-${var.env}"
    storage_account_name = "sttfstate${var.env}001"
    container_name       = "tfstate"
    key                  = "network.tfstate"
    use_azuread_auth     = true
  }
}

module "network" {
  source  = "gitlab.example.com/acme/network/azurerm"
  version = var.network_module_version
}

Only values knowable before init are allowed (variables and locals derived from them, not resources). This removes one of Terragrunt's original reasons to exist, though not the orchestration side.

.tofu files

If both main.tf and main.tofu exist, OpenTofu loads main.tofu and ignores main.tf. That lets one module support both tools: OpenTofu-specific syntax in .tofu files, portable syntax in .tf. Terraform ignores .tofu files entirely.

Migrating Terraform → OpenTofu

From Terraform up to 1.5.x, it's a binary swap. From later Terraform versions, check the OpenTofu migration guide for your exact source version, because state written by newer Terraform may include features OpenTofu handles differently.

# 1. Back up state
terraform state pull > pre-tofu-backup.tfstate

# 2. Install tofu (tenv tofu install 1.12.x)

# 3. Re-initialise; the lock file is regenerated against registry.opentofu.org
tofu init -upgrade

# 4. Expect no changes
tofu plan

# 5. Apply a no-op to write state with tofu (optional, makes the switch explicit)
tofu apply

Then update CI images, required_version expectations, version files (.opentofu-version), and any tooling that calls terraform. Terragrunt prefers tofu automatically when it's on the PATH.

Rolling back is easy only until you enable OpenTofu-only features (encryption especially). Decide on direction before turning those on.

Choosing

Lean towards Terraform when:

  • You use or plan to use HCP Terraform (Stacks, policy sets, private registry, run management)
  • You want actions and list resources/query
  • Your organisation prefers a vendor-backed product with commercial support from HashiCorp/IBM
  • The BSL doesn't affect you (it restricts offering Terraform as a competing hosted product, not using it)

Lean towards OpenTofu when:

  • Open-source licensing matters to you or your organisation's policy
  • You want state encryption, dynamic prevent_destroy, for_each on providers, or -exclude
  • Your automation platform is OpenTofu-first (Scalr beyond 1.5.7, GitLab's CI component)
  • You want early evaluation in backends without Terragrunt

Either way: keep shared modules portable (no .tofu-only or Terraform-only features in modules others consume), and test them against both if you have consumers on both.