Skip to content

OpenTofu — fork of Terraform, and how to migrate

OpenTofu is the Linux Foundation fork of Terraform after the BSL license change. Compatibility status, the migration steps, and the registry consideration.

OpenTofu is the fork of Terraform that the Linux Foundation took over after HashiCorp re-licensed Terraform under the BSL in August 2023. For most clients running Terraform 1.5.x or earlier, the migration is a drop-in terraform → tofu rename in the CI runner and a state file untouched. For anyone using Terraform Cloud, private provider registries, or features that landed in Terraform 1.6+ after the fork, there are real choices to make. This article walks through the migration we run for clients who decided to leave HCL-the-binary behind.

How to verify

tofu version
tofu providers
tofu init -upgrade
tofu plan -no-color
tofu state list
diff <(tofu plan -no-color) <(terraform plan -no-color)

The diff command is the actual smoke test: if tofu plan and terraform plan produce the same output against the same state and same modules, the migration is mechanical from there. Any difference deserves investigation — usually a provider version drift or a feature that one of the two doesn’t support.

What’s happening

OpenTofu forked from Terraform 1.5.x. It is a drop-in replacement for any configuration that worked on Terraform 1.5.x and earlier, with the same state format, same .tf and .tfvars syntax, same provider protocol, and the same backend types. The two have since diverged: OpenTofu has features Terraform doesn’t (provider iteration, encryption at rest for state, dynamic provider configuration); Terraform has features OpenTofu doesn’t (import blocks in 1.7, removed blocks in some forms, Stacks in 1.9+).

The registry is where the licensing story shows up. The HashiCorp Terraform Registry hosts provider binaries; OpenTofu has its own registry. For official providers (hashicorp/aws, hashicorp/google, hashicorp/azurerm, etc.) both registries serve the same binaries. For third-party providers (integrations/github, cloudflare/cloudflare), both usually serve them; for niche providers, one might lag the other.

State compatibility is bidirectional today: a state file written by Terraform 1.5.x can be read by OpenTofu and vice versa. State written by features that only exist in one fork (e.g. Terraform’s import block writing import-time metadata) can become unreadable to the other. So once you commit to one, treat state as one-way.

The procedure

  1. Pin current Terraform version. Lock CI to the exact terraform version you have today — this stops accidental upgrades during the migration window.

  2. Install OpenTofu on the workstation and in the CI runner:

    curl -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh
    chmod +x install-opentofu.sh
    ./install-opentofu.sh --install-method standalone
    tofu version
  3. Smoke test in a sandbox. Pick a non-production stack:

    cd live/staging/us-east-1/networking
    cp -r .terraform .terraform.bak
    tofu init -upgrade
    tofu plan -no-color > /tmp/tofu.plan
    terraform plan -no-color > /tmp/tf.plan
    diff /tmp/tf.plan /tmp/tofu.plan

    Empty diff is the expected outcome.

  4. Apply with tofu. Same sandbox stack:

    tofu apply
    tofu state pull > state-after-tofu.json
  5. Swap the binary in CI. If you use Atlantis, change TERRAGRUNT_TFPATH=tofu or set the workflow to call tofu. If you use Spacelift, set terraform_workflow_tool = "OPEN_TOFU" on the stack. GitHub Actions: replace hashicorp/setup-terraform with opentofu/setup-opentofu.

  6. required_version. Terraform configs commonly have terraform { required_version = ">= 1.5" }. OpenTofu reports its own version (1.x); both should match the constraint. If you have ~> 1.5.0, broaden it before swapping.

  7. Registry sources. Provider sources are usually hashicorp/aws. OpenTofu resolves these by trying its registry first, then optionally falling back. For private modules from Terraform Registry’s private registry feature, you may need to switch to a generic git source or set up a private OpenTofu registry mirror.

  8. State encryption (optional, OpenTofu-only). OpenTofu can encrypt state at rest before writing to the backend:

    terraform {
      encryption {
        key_provider "pbkdf2" "key" { passphrase = var.state_passphrase }
        method "aes_gcm" "method" { keys = key_provider.pbkdf2.key }
        state { method = method.aes_gcm.method }
      }
    }

    This is genuinely useful for backends that store state in cloud storage without their own at-rest encryption — but it’s also a footgun: lose the passphrase, lose access to the state.

  9. Decommission Terraform. Once every stack runs on tofu, remove the Terraform binary from CI runners. Tag the migration commit so the next engineer can find when the swap happened.

Common pitfalls

  • Forgot one stack. A leftover stack with terraform apply still runs and may write state in a form tofu later rejects. Audit with grep -r "terraform " ci-configs/ after the swap.
  • required_providers lock file mismatch. .terraform.lock.hcl is written by whichever binary ran last. If your team runs both, the lock file flip-flops. Standardize before migrating.
  • Private registry credentials. Terraform Cloud–style private registry tokens may not work with OpenTofu. Move private modules to a git source (source = "git::ssh://git@github.com/acme/tf-modules.git//app?ref=v1.0.0") for portability.
  • CI image baked with terraform. Container images with RUN apt install terraform from HashiCorp’s apt repo won’t get OpenTofu. Update the Dockerfile.
  • Editor/IDE integrations. Some VS Code extensions assume terraform on PATH. Either alias terraform=tofu or update the editor config.

We run Terragrunt + Atlantis on top of either Terraform or OpenTofu depending on the client’s license posture; the operating model — the repo layout, the PR workflow, the policy library, the state backend hygiene — is identical. The migration itself is a focused project we deliver inside /en/services/managed-operations/; the longer-term operation of the IaC platform is the steady-state engagement.