What is OpenTofu?

Spacelift team - May 29 - - Dev Community

In this post, we will explore OpenTofu, its features, and basic commands. We will also answer some of the most important questions about OpenTofu that we have seen on different channels.

What is OpenTofu?

OpenTofu is a fully open-source Terraform fork, a drop-in replacement for Terraform version 1.6 that is backward compatible with all prior versions of Terraform. It's a viable alternative to HashiCorp's Terraform that will expand on Terraform's existing concepts and offerings.

OpenTofu is an open-source Infrastructure as Code (IaC) tool that enables you to define, preview, and apply infrastructure changes across multiple cloud providers. It uses declarative OpenTofu language to manage infrastructure resources.

It was created by the initiative of OpenTF supported by Gruntwork, Spacelift, Harness, Env0, Scalr, and other companies as a response to HashiCorp's license changes to the BSL in August 2023. OpenTofu was forked from Terraform version 1.5.6. and retained all the features and functionalities that had made Terraform popular among developers, while also introducing improvements and enhancements. The project is now a part of the Linux Foundation, with the ultimate goal of joining the Cloud Native Computing Foundation (CNCF).

The first stable version of OpenTofu was released in January 2023 (read here), and recently, OpenTofu has released its 1.7 version. The latest OpenTofu version comes packed with new features, enhancements, and bug fixes that aim to elevate the user experience, improve overall functionality, and boost your infrastructure as code management.

Why was OpenTofu created?

OpenTofu was created to ensure the Terraform ecosystem continues to flourish into the future. It was created by the OpenTF initiative in response to HashiCorp's license change to the BSL.

The new licensing terms for Terraform, specifically the Business Source License (BSL) and HashiCorp's additional use grant, make it difficult for companies, vendors, and developers using Terraform to know whether what they are doing is allowed or not under the license.

Hashicorp's FAQs offer some reassurance to end users and system integrators for now, but questions arise over the implications of the licensing terms for future usage. The potential for changes to the company's definition of "competitive" or "embedding" or further modifications to the license to make it a closed source creates uncertainty for Terraform users.

We strongly believe that Terraform should stay open-source, as it is a project used by many companies, and many people have contributed to getting Terraform where it is today. Terraform wouldn't be as successful as it is without the community's effort in building many supporting projects around it.

History of OpenTofu

The history of OpenTofu (originally named OpenTF) started on August 10th, 2023, when HashiCorp announced that going forward they will be changing the license on their core products, including Terraform, to a Business Source License (BSL). Unlike the Mozilla Public License (MPL v2) that their products were previously licensed under, BSL is not an open source license. While it still allows similar freedoms for individuals to use, share, and modify, it places restrictions on various forms of commercial use.

Since the announcement of the license change there has been a tumultuous amount of activity, speculation and discussion about the future of Terraform and what can be done to not lose such a precious and important asset. As a result, in the true spirit of our community, many companies and individuals have come together in unison to act as one under the umbrella of OpenTF (currently OpenTofu).

On August 15th, OpenTF released its manifesto. The manifesto lays out OpenTFs intent and goals and sets out a roadmap to ensure the continued survival of Terraform as an open-source tool.

The OpenTofu initiative was launched with significant initial support, boasting over 18 full-time equivalents (FTEs) committed to the project from four companies. The manifesto has been endorsed by over 140 companies, involving 11 projects with the participation of over 700 individuals. Moreover, the manifesto has received more than 35,000 GitHub stars, and the fork itself has garnered over 6,000 stars in just one week.

On September 5th, OpenTofu officially published the fork, and on September 20th, the project officially joined the Linux Foundation.

Joining the Linux Foundation is significant because it provides OpenTofu with a stable and well-respected organizational home. This move ensures that the project remains independent and avoids the risk of being controlled or influenced by a single company, which is a concern that many in the open-source community share.

What are the differences between Terraform and OpenTofu?

Right now, there are not many differences between Terraform and OpenTofu, related to functionality. However, one of the biggest differences that can be easily observed is that OpenTofu listens to the community.

A couple of years ago, there were many requests for Terraform to support state encryption. This was especially requested because everything that went into the state file is in a plain-text format. For reasons that nobody knows, this feature was not implemented in Terraform, even though it was crucial for many companies that were using it. OpenTofu has released state encryption in its 1.7 version, fixing one of the biggest pains that users had with Terraform.

Apart from this, OpenTofu prioritizes feature implementation based on the community's input. There is an issue ranking system in place that you could take advantage of and ensure that the most relevant features are getting implemented.

OpenTofu features

OpenTofu has many features that help your overall infrastructure as code journey:

  1. Open-source and community-driven - the fact that OpenTofu is open-source means that everyone can contribute with code/documentation/ideas to improve the tool. With OpenTofu, you can ensure your voice is heard, and the most important features will be implemented.
  2. Execution plan - OpenTofu execution plan outlines the actions that will be taken on your infrastructure without doing the actual changes. This provides an opportunity to understand what will happen and make decisions accordingly.
  3. Encrypted state management - OpenTofu is stateful, keeping track of your infrastructure using a state file (that can be optionally encrypted) and ensuring that infrastructure changes are applied consistently.
  4. Provider ecosystem - Vast ecosystem making OpenTofu work with a variety of providers (cloud, containers, databases, etc.).
  5. Modules and reusability - OpenTofu is developed to give you the flexibility to create reusable components.

đź’ˇ You might also like:

Basic OpenTofu commands

Here is a list of the most useful OpenTofu commands:

  • tofu init - Initilializes your working directory, downloading your modules, and preparing it to run other commands
  • tofu plan - Creates an execution plan based on your configuration, showing you the resources that will be created, changed, or deleted
  • tofu apply - Applies changes (create/modify/delete) to your infrastructure resources
  • tofu destroy - Destroys all the infrastructure resources that were deployed using your configuration
  • tofu validate - Checks if your configuration is valid
  • tofu show - Shows the current state
  • tofu state - Helps you do advanced state management

How to get started with OpenTofu - Tutorial

These are the steps you need to take to get started and become professional with OpenTofu:

  1. Install OpenTofu.
  2. Get familiar with the basic components:
    1. Providers - will help you authenticate to the cloud provider/service you want to use with OpenTofu
    2. Resources - describe your infrastructure services/components as code
    3. Data sources - use existing infrastructure services/components
    4. Variables - parametrize your configuration
    5. Outputs - view the value of specific components
    6. Local variable - assign a value to an expression
    7. Modules - reusable configurations
    8. State - OpenTofu is stateful, keeping track of your infrastructure changes using a state file
  3. Write your OpenTofu code.
  4. Plan/Apply/Destroy - view an execution plan of what will happen based on your code, apply the infrastructure changes, and after you don't need the resources anymore, destroy them.
  5. Get familiar with advanced concepts:
    1. Loops and conditional statements (for_each, count, for, if, ternary)
    2. Dynamic blocks
    3. Test feature
    4. Variable validations
  6. Integrate with a dedicated infrastructure management platform like Spacelift.

Check out our OpenTofu tutorial to learn more.

Why should you use OpenTofu?

Key advantages of using OpenTofu instead of Terraform:

  • Open-source nature - There are no restrictions on how you can use OpenTofu, either for commercial or personal use. The open-source nature of OpenTofu embodies the principles of openness and collaboration that characterize the tech community.
  • Dynamic community - Developer contributions will make the project more robust and adaptable to different use cases. Bugs and issues will be identified and resolved quickly to ensure reliability and stability.
  • Fast, reliable support - The growing community behind OpenTofu not only gives everyone the opportunity to influence the development of new features, but it also supplies the resources to ensure these features and bug fixes will be introduced rapidly.
  • Minimal risk - OpenTofu is published under MPL and is a part of the Linux Foundation (with the goal of joining CNCF), which provides the guarantee the tool remains truly open-source, forever.

Read more: Why Should You Switch to OpenTofu?

Common questions about OpenTofu

Let's answer some of the most important questions about OpenTofu that we have seen in different channels.

What is OpenTofu used for?

OpenTofu is used for managing your infrastructure as code and works with various cloud providers (AWS, Microsoft Azure, Google Cloud, etc.), databases (MongoDB, PostgreSQL, MySQL, etc.), version control systems (GitHub), container orchestration (Docker, Kubernetes, Rancher, etc.), and more.

Is OpenTofu production ready?

Yes. OpenTofu is production-grade and is suitable for production use without any exceptions. There is no need to enter any separate, individually negotiated agreements regarding the production use of the tool.

Is OpenTofu stable?

OpenTofu is stable, and the latest stable release is 1.7. Being a member of the Linux Foundation provides peace of mind that OpenTofu will remain stable and continue to grow and improve.

How can I migrate from Terraform to OpenTofu?

Migrating from Terraform to OpenTofu involves a simple binary change in your pipeline, replacing Terraform with OpenTofu.

If you are running Terraform locally, which is something we don't recommend, you can simply add the OpenTofu binary in your PATH, and both OpenTofu and Terraform can co-exist if that is something you want.

To learn more on how to migrate from Terraform to OpenTofu, watch this short video tutorial.

OpenTofu remains a drop-in replacement for its predecessor Terraform™ 1.5, and has easy migration paths from later versions. Check out the overhauled migration guides for detailed migration instructions. You can find the full list of changes and comprehensive examples in the documentation.

Is OpenTofu using the same registry as Terraform?

OpenTofu has its own registry, and its implementation can be found here. The OpenTofu CLI uses the module and provider registry protocols to discover modules and providers.

Can OpenTofu use Terraform providers and modules?

OpenTofu is compatible with existing Terraform providers and modules. This means that any provider that works with Terraform can also be used with OpenTofu.

What providers are supported by OpenTofu?

OpenTofu supports a wide range of providers that enable it to interact with various tools, services, and APIs. The Public OpenTofu Registry hosts providers for most major infrastructure platforms. For example, OpenTofu works with all cloud vendors such as AWS, Azure, or GCP, as well as other platforms like Kubernetes, Helm, VSphere, and Spacelift.

Will OpenTofu work with my existing state file?

OpenTofu works with an existing state file, up to state files created with a version prior to Terraform's 1.5.x.

Is OpenTofu going to keep pace with the upstream Terraform releases? How will this evolve?

No, the short answer is that OpenTofu will most likely not keep pace with upstream Terraform releases. The community will dictate what they need and want to see in OpenTofu.

Some of the Terraform features you've been waiting for ages are now available with the 1.7.0 version of OpenTofu.

Who owns OpenTofu?

OpenTofu is a part of the Linux Foundation following the same management structure as other projects within the Linux Foundation. The OpenTofu team submitted it's CNCF application in early 2024. Once its accepted the project and the associated trademarks will be donated to CNCF.

Who is behind OpenTofu? Are there any big organizations backing OpenTofu?

OpenTofu is backed and supported by an enormous community of large companies, projects, and individuals. The founding companies and initial maintainers of OpenTofu are Spacelift, Harness, Gruntwork, Env0, and Scalr.

The current community size behind the OpenTofu initiative:

  • Almost 144 Companies
  • Over 10 Projects
  • Over 718 Individuals

The manifesto repository has over 36k stars.

OpenTofu's repository has over 20k stars.

Numerous engineers from various companies, including some that compete with each other, have collaborated over the past week to bring OpenTofu to life. OpenTofu is a part of the Linux Foundation. Having a foundation responsible for the project ensures the tool stays vendor-neutral.

Where does the OpenTofu name come from?

The name had to be short, as there are many commands engineers need to run, and not all of them are keen on setting up aliases in the CLI. At the same time, choosing a name for any kind of business is a hard deal, so choosing something easy to remember and building a great logo will take you a long way.

What is the future of OpenTofu?

The future of OpenTofu is in the hands of the community. Being under the Linux Foundation's umbrella, OpenTofu will continue to be open-source and listen to the community's feedback.

What new features can we expect from OpenTofu?

In the last few months since the first stable release the OpenTofu community and the core team have worked hand in hand to bring functionality to OpenTofu that has been requested for years. The latest OpenTofu version (1.7) comes packed with new features, enhancements, and bug fixes that aim to elevate the user experience, improve overall functionality, and boost your infrastructure as code management. Read more about OpenTofu 1.7 here.

OpenTofu is first and foremost a community-driven project. Priorities can shift based on the community's voice, so you can request features and create RFC's to implement them.

You can always check the milestones, the issue ranking system, LinkedIn or X accounts, to see what kind of features are coming up from OpenTofu.

Using OpenTofu with Spacelift

Spacelift supports OpenTofu out of the box, giving you the ability to easily build your OpenTofu workflows. From the UI, when you are creating a stack you just need to choose the Terraform/OpenTofu vendor and select OpenTofu as your workflow tool. You can then choose the OpenTofu version you want to run, and enable/disable some other options.

opentofu with spacelift

As OpenTofu works out of the box with Spacelift, you can easily take advantage of all of the features Spacelift offers, such as:

  • Plan, approval, push, and notification policies -- control what kind of resources engineers can create, what kind of parameters they can have, how many approvals you need for runs, what kind of tasks engineers can run, what happens when a PR is opened/merged, and where to send notifications
  • Drift detection and optional remediation
  • Multi-infrastructure workflows with dependencies and shareable output (easily combine, for example, OpenTofu and Ansible, and whenever you are creating a new virtual machine, send the ip/hostname to the Ansible inventory as a dependency and then trigger the Ansible stack)
  • Native integrations with AWS, Microsoft Azure, and Google Cloud for dynamic credentials
  • Integrations with any third-party tools and the ability to build custom policies for them via custom inputs
  • Self-service infrastructure via blueprints

Key points

OpenTofu is the future of the Terraform ecosystem, and we plan to do everything right. We care about the community, and we care about having a truly open-source project to support your IaC needs.

If you want the best possible experience with OpenTofu, create a free account with Spacelift or book a demo with one of our engineers to help you elevate your OpenTofu workflow.

Written by Flavius Dinu.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .