Skip to main content

How to Upgrade or Install Versions of Terraform

Problem

You want to install or upgrade to a specific version of terraform, ideally, without affecting anything that needs newer or older versions of terraform.

Solution

Install Desired Version of Terraform

First, make sure you’ve installed the latest version of terraform in Geodesic. Installation instructions will vary depending on if you’re using Alpine, Ubuntu, or CentOS.

We publish special packages for terraform to support installing multiple versions simultaneously. We support package pinning going back as far as Terraform 0.11 (remember those days? 😵 ).

info

We support installing multiple versions of terraform without using a version manager like tfenv.

You’ll want to install the desired version of terraform by adding it to the Dockerfile for your infrastructure repository.

E.g.

RUN apt-get install -y terraform-1

https://github.com/cloudposse/packages

Terraform Releases

https://github.com/hashicorp/terraform/releases

Here’s a list of our supported versions of terraform (these are updated nightly by a github action)

Terraform 1.xhttps://github.com/cloudposse/packages/tree/master/vendor/terraform-1Ubuntu: apt-get install -y terraform-1
Alpine: apk add terraform-1@cloudposse
Terraform 0.15https://github.com/cloudposse/packages/tree/master/vendor/terraform-0.15Ubuntu: apt-get install -y terraform-0.15
Alpine: apk add terraform-0.15@cloudposse
Terraform 0.14https://github.com/cloudposse/packages/tree/master/vendor/terraform-0.14Ubuntu: apt-get install -y terraform-0.14
Alpine: apk add terraform-0.14@cloudposse
Terraform 0.13https://github.com/cloudposse/packages/tree/master/vendor/terraform-0.13Ubuntu: apt-get install -y terraform-0.13
Alpine: apk add terraform-0.13@cloudposse
Terraform 0.12https://github.com/cloudposse/packages/tree/master/vendor/terraform-0.12Ubuntu: apt-get install -y terraform-0.12
Alpine: apk add terraform-0.12@cloudposse
Terraform 0.11https://github.com/cloudposse/packages/tree/master/vendor/terraform-0.11Ubuntu: apt-get install -y terraform-0.11
Alpine: apk add terraform-0.11@cloudposse
tip

You can pin the version of terraform using update-alternatives as well as in the component configuration.

After installing the desired version of terraform, make sure you know How to Switch Versions of Terraform, and don’t forget to update the component’s configuration in the stack for both Spacelift and command line.