Blog

Migrating from Terraform to OpenTofu: A Step-by-Step Guide with Key Benefits

Picture of Dimitar Zafirov
Dimitar Zafirov
DevOps & Cloud Engineer
29.07.2025
Reading time: 3 mins.
Last Updated: 22.06.2026

Table of Contents

In the rapidly evolving world of Infrastructure as Code (IaC), OpenTofu has emerged as a powerful open-source alternative to Terraform, offering a more open, community-driven, and flexible future. Suppose you’re considering a switch or just want to stay current. In that case, this guide walks you through everything you need to know about migrating from Terraform to OpenTofu – from preparation to leveraging its newest features.

The most significant and important difference between OpenTofu and Terraform is the licensing. OpenTofu is open-source under the MPL 2.0, and Terraform is under the BSL. Being open-source makes OpenTofu community-driven, and this enables the community to influence the implementation of certain features without being directly influenced by any vendor. However, Terraform is influenced directly by its vendor, HashiCorp, when developing new features.

OpenTofu also offers state encryption, a feature the Terraform community has requested for the last five years but has never received. 

This article explains how to encrypt your state.

In addition to this, with OpenTofu 1.8, you can leverage early variable evaluation, meaning that you can take advantage of variables and locals inside your Terraform block and inside your module sources and versions.

As OpenTofu and Terraform continue to evolve, they will probably diverge, meaning that more key differences will emerge in the future. OpenTofu 1.9.1 started as a fork of Terraform and maintains compatibility but also adds new improvements.

  • Backward-compatible with Terraform 1.5+, including most modules and providers
  • Faster plan/apply performance
  • Improved state file handling
  • CLI improvements and bug fixes not yet in Terraform 1.7.1.
  • Benefit: You get a familiar experience with a potentially better-performing tool

Commitment to Backward Compatibility

  • OpenTofu aims to remain compatible with the Terraform ecosystem (providers, modules) while improving openness
  • Benefit: Easy migration path from Terraform with little disruption

Vendor Independence

  • No reliance on a single vendor (like HashiCorp) for tooling, updates, or support
  • Benefit: More sustainable for long-term infrastructure planning
Open Tofu vs Terraform

*** Issue ranking system

Before doing anything, always back up your state file:

cp terraform.tfstate terraform.tfstate.backup

Or if using remote state (e.g., S3):

aws s3 cp s3://your-bucket/path/to/terraform.tfstate ./terraform.tfstate.backup

Install OpenTofu via Homebrew (on macOS):

brew install opentofu/opentofu/opentofu

If you are using OpenTofu in an existing Terraform project:

tofu init

This will reinitialize the backend, download providers, and prepare the project.

Run a plan to ensure compatibility:

tofu plan

Then apply changes (if any):

tofu apply

This ensures OpenTofu is working with your existing state and configuration.

Update your required version in main.tf:

terraform {

  required_version = ">= 1.9.1"

}

Then upgrade your providers (if needed):

tofu init -upgrade

And verify:

tofu validate
tofu plan

In your tofu block, enable state encryption using an encryption key (e.g., AWS KMS):

tofu {

  state {

    encryption = {

      provider = "aws"

      key_id   = "arn:aws:kms:us-east-1:123456789012:key/xxxx-xxxx-xxxx"

    }

  }

}

Then re-initialize and encrypt state:

tofu init

tofu plan

You can safely switch back to Terraform if:

  • The provider versions are compatible.
  • You do not use OpenTofu-only features like encrypted state or early variable evaluation.

terraform init

terraform plan

alias terraform=’tofu’

If you use for example, v1.7.1 OpenTofu version and your Terraform version is the same:

  1. No need to update provider version.
    1. If you want to migrate to 1.9.1 for example, you need to update the terraform provider version to 1.9Some terraform features are not supported by tofu, or need to be updated
    1. If you use lifecycle  in some of your modules, you will have to update/prepare the modules first


           If you use directly v1.9.1:

  1. No issues if update the terraform provider version directly to 1.9 and run “tofu init/plan“ with Tofu version 1.9.1 and then roll back the provider version to 1.7 and run “terraform init/plan”. The state file will not be broken!

At ITGix, we promote sustainable, vendor-neutral, and flexible DevOps practices. OpenTofu embodies all of these principles. Its backward compatibility, community-driven roadmap, and added security features make it a smart choice for teams seeking long-term IaC stability.

Newsletter for Tech experts

Signal, not noise -

straight to your inbox.

Join 12,000+ engineers and business leaders getting field notes on SRE, DevOps and cloud- native reliability.

Deep-dive tech blogs & case studies
Emerging tech, curated

Your Work Email

We respect your inbox. Read our Privecy Policy

More Posts

As IPv6 adoption continues to grow, organizations running workloads on AWS increasingly need networking architectures that can support both IPv4 and IPv6 traffic. While AWS provides native IPv6 capabilities, integrating...
Reading
In AWS, a Client VPN Endpoint is a managed, serverless cloud VPN service that enables users to securely access resources within an AWS VPC (Virtual Private Cloud). When creating this...
Reading
Get In Touch
ITGix provides you with expert consultancy and tailored DevOps services to accelerate your business growth.
Newsletter for
Tech Experts
Join 12,000+ business leaders and engineers who receive blogs, e-Books, and case studies on emerging technology.