How to Install OpenTofu

· Updated · 1 min read · Terraform & OpenTofu Tutorials

Previously named OpenTF, OpenTofu is an open-source, community-driven fork of Terraform managed by the Linux Foundation. It uses the same HCL language and works with the same providers and modules.

OpenTofu can be installed on several operating systems using a package manager or by downloading a package from the OpenTofu GitHub Releases repository. This tutorial shows how to install it on Ubuntu. For other operating systems, see the official documentation.

Install OpenTofu with the installer script #

The installer script of the OpenTofu project detects the operating system, adds the OpenTofu repository and installs the package. Download it, read it, and run it:

$ curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh
$ chmod +x install-opentofu.sh
$ less install-opentofu.sh
$ ./install-opentofu.sh --install-method deb
$ rm -f install-opentofu.sh

Because the repository is added to the system, OpenTofu is upgraded with the rest of the packages (sudo apt update && sudo apt upgrade).

Install OpenTofu manually from the GitHub releases #

  1. Visit the OpenTofu GitHub Releases page, expand the list of assets and identify the package for your architecture, for example tofu_<version>_amd64.deb for Ubuntu on AMD/Intel 64 bits or tofu_<version>_arm64.deb for ARM.

  2. Download the package with wget:

    $ wget https://github.com/opentofu/opentofu/releases/download/v<version>/tofu_<version>_amd64.deb
  3. Install it with dpkg:

    $ sudo dpkg --install tofu_<version>_amd64.deb

Test the OpenTofu installation #

$ tofu version
OpenTofu v1.x.x
on linux_amd64

Upgrade OpenTofu #

Install the new version using the same method. Then run tofu init -upgrade in your projects to update the providers inside the version constraints. If the backend configuration has changed, run a state migration:

$ tofu init
Initializing the backend...
...
$ tofu init -migrate-state

To use different versions of OpenTofu in different projects, see tenv in the Terraform Tools section.

Next Steps #

#OpenTofu #Terraform