TNS
VOXPOP
What news from AWS re:Invent last week will have the most impact on you?
Amazon Q, an AI chatbot for explaining how AWS works.
0%
Super-fast S3 Express storage.
0%
New Graviton 4 processor instances.
0%
Emily Freeman leaving AWS.
0%
I don't use AWS, so none of this will affect me.
0%
Infrastructure as Code / Open Source / Software Development

Getting Started with OpenTofu Alpha

A quick guide to installation and importing Terraform state files.
Oct 18th, 2023 9:41am by
Featued image for: Getting Started with OpenTofu Alpha
Image from Denis Belitsky on Shutterstock.

In the ever-evolving landscape of Infrastructure as Code, the Linux Foundation’s recent unveiling of the OpenTofu project marks a watershed moment. Launched on Sept. 20, at Open Source Summit Europe, in Bilbao, Spain, OpenTofu has emerged as a compelling alternative to Hashicorp’s Terraform, especially in light of the company’s recent shift from a Mozilla Public License to a Business Source License.

Backed by companies like Harness, Gruntwork and Spacelift, with a starting commitment of at least 18 full-time developers for the next five years, OpenTofu is not just another project but a collective commitment to open collaboration and innovation. One of its most promising features is its commitment to backward compatibility, making it an attractive option for those considering to migrate from other Infrastructure as Code tools.

In this quick guide, we’ll walk you through the steps to get started with the OpenTofu alpha release.

How Do I Download OpenTofu?

Go to the release page of the OpenTofu repo and select the binary corresponding to the operating system on which you will be using OpenTofu.

What Is Included?

First, a complete renaming of Terraform to OpenTofu had to be done for legal reasons. The team also had to ensure a suitable OpenTofu registry was in place, as the existing Terraform registry is only allowed to be used with Terraform.

From an end-user perspective, it is just a difference in the command line. Instead of calling terraform, you will now call tofu. All of the existing Terraform commands that were present from 1.5.x and below will continue to work.

What Do I Need to Know about the Provider Registry?

The original Terraform registry is essentially a metadata server that shows all the information regarding the providers, with the providers actually living in third-party sources like GitHub. The team created its own registry, ensuring that all existing 2,260 providers will continue to work without violating Hashicorp terms of service.

The release of the registry is considered alpha, with work underway to make a production-ready registry. If you’re interested in contributing to the registry, you can find the repo here.

OpenTofu Commands

Once downloaded, there is little difference between the Terraform 1.5.x and OpenTofu commands. The basic commands remain the same:

  • tofu init — Initializes the working directory where the configuration files are located. All modules, providers and plug-ins are downloaded or upgraded during this time.
  • tofu plan — Executes a “dry run,” meaning that the resources are not actually created; instead you can see a preview of what to expect if the apply were to happen.
  • tofu apply — Executes a run in which the resources defined in your configuration files are actually created.

How Do I Migrate from Terraform to OpenTofu?

It’s simple; you only need to run OpenTofu commands on your existing state files. As seen here, I have an existing state file that was created using Terraform 1.5.0 and the null resource provider:


I added the OpenTofu binary, and then ran a tofu init:


Ran a tofu plan:


For good measure, I ran a tofu apply, and we can see that the only thing that changed was the version, which now shows 1.6.0, which is the current version of OpenTofu I am testing on.


Everything worked as expected, and there was no need to do any major migrations; just update the binary.

Use It in Scalr Today!

To switch to OpenTofu in Scalr, you simply need to update your workspace settings. Go to your pipeline settings and search for version 1.6.0 and save. The next run will update your workspace to use OpenTofu!

How Do I Report Issues or Contribute?

With any alpha release, it is expected that improvements will be needed and bugs will be identified. If you are interested in contributing or find an issue, please feel free to open an issue in the public repo here.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Pragma, Spacelift.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.