Terraform on Ubuntu 26.04 LTS - sudo-rs, APT Rollback, and Hardened Base Images
Install and run Terraform on Ubuntu 26.04 LTS Resolute Raccoon. Covers sudo-rs as default, APT 3.2 rollback, Kernel 7.0, Wayland-only, ROCm, and building...
Terraform
Learn how to upgrade Terraform to a specific version using tfenv, a version manager that simplifies managing multiple Terraform versions. This guide is.
Upgrading Terraform to a specific version, especially when you're not ready to jump to the latest release, can seem challenging at first. This guide provides a clear pathway for users who need to manage multiple versions of Terraform, particularly when a precise upgrade path is required for compatibility or testing purposes. Let's dive into how you can upgrade Terraform to a specific version, such as from v0.11.13 to v0.11.14, before considering a major upgrade to v0.12.0 or beyond.
For many users, the default upgrade path using package managers like Homebrew on macOS may not offer the control needed for incremental upgrades. Directly upgrading to the latest version (e.g., from v0.11.13 to v0.12.0) might introduce changes that require significant adjustments to your Terraform configurations. The goal here is to achieve a controlled upgrade to v0.11.14, ensuring compatibility and stability before making a larger version leap.
Enter tfenv, a Terraform version manager that simplifies the process of managing multiple Terraform versions. It offers a seamless way to switch between versions and is particularly useful in scenarios where incremental upgrades are necessary. Here's how to use tfenv to upgrade Terraform to a specific version on macOS:
First, if you haven't already installed tfenv, you can do so using Homebrew:
brew install tfenvBefore deciding on the version to upgrade to, you might want to see a list of available versions. This can be done with:
tfenv list-remoteThis command displays all available Terraform versions, helping you identify the specific version you need.
Once you've decided on the version (e.g., v0.11.14), you can install it using:
tfenv install 0.11.14tfenv will fetch and install the specified Terraform version, making it the active version on your system.
If you ever need to switch to another version, tfenv makes it easy:
tfenv use 0.12.0This command switches the active Terraform version to v0.12.0.
.terraform-version file to your project directory with the desired version number, tfenv can automatically switch to the correct Terraform version for that project.unlink Terraform before using tfenv:brew unlink terraform# Download a specific version directly
TERRAFORM_VERSION="1.8.5"
wget "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
unzip "terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
sudo mv terraform /usr/local/bin/
terraform versionBefore upgrading Terraform versions, follow this process:
# 1. Check current version
terraform version
# 2. Review the changelog for breaking changes
# https://github.com/hashicorp/terraform/blob/main/CHANGELOG.md
# 3. Back up your state
terraform state pull > backup-$(date +%Y%m%d).tfstate
# 4. Install the new version
tfenv install 1.8.5
tfenv use 1.8.5
# 5. Initialize with the new version
terraform init -upgrade
# 6. Run plan to check for issues
terraform plan
# 7. Pin the version in your project
echo "1.8.5" > .terraform-versionterraform {
# Pin to minor version — allows patch updates
required_version = "~> 1.8.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}| Constraint | Meaning | Example |
|---|---|---|
= 1.8.5 | Exact version | Only 1.8.5 |
~> 1.8.0 | Minor version range | 1.8.0 to 1.8.x |
~> 1.8 | Major version range | 1.8.0 to 1.x.x |
>= 1.5, < 2.0 | Range | 1.5.0 to 1.x.x |
| Command | Description |
|---|---|
tfenv list | Show installed versions |
tfenv list-remote | Show all available versions |
tfenv install 1.8.5 | Install specific version |
tfenv install latest | Install latest version |
tfenv use 1.8.5 | Switch to a version |
tfenv uninstall 1.5.0 | Remove a version |
Use tfenv to manage multiple Terraform versions — install, switch, and pin versions per project with .terraform-version files. Always back up state before upgrading, check changelogs for breaking changes, and pin required_version in your configuration to keep your team aligned.
Install and run Terraform on Ubuntu 26.04 LTS Resolute Raccoon. Covers sudo-rs as default, APT 3.2 rollback, Kernel 7.0, Wayland-only, ROCm, and building...
Learn the purpose and benefits of Terraform modules and how they enhance reusability, organization, and scalability in managing infrastructure as code.
Complete Terraform commands reference. Learn terraform init, plan, apply, destroy, state, import, output, workspace, fmt, validate
Encountering the Inconsistent Dependency Lock File error in Terraform? This guide explains the causes and provides step-by-step solutions to resolve the.