Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

unable to update terraform version

I already have the latest version in my provider.tf files:

  required_providers {
    archive = {
      source  = "hashicorp/archive"
      version = "2.2.0"
    }
    aws     = {
      source  = "hashicorp/aws"
      version = "3.72.0"
    }
  }

However, when I check terraform versionon my terminal, I get this:

Terraform v1.0.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/archive v2.2.0
+ provider registry.terraform.io/hashicorp/aws v3.72.0

Your version of Terraform is out of date! The latest version
is 1.1.4. You can update by downloading from https://www.terraform.io/downloads.html

I already tried terraform init -upgradebut that didn’t make a difference either.I also manually downloaded terraform’s new version from the website but my terminal still shows 1.0.7.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Due to the old Terraform version, I face other errors. How can I update to the latest version using the terminal?

>Solution :

There is a difference between providers and terraform binary. With the command you are using you would update the provider and module versions. From your question I understand you downloaded the binary to your Mac. That of course is not enough. You have to replace the old binary with the new one. The easiest way to do this is to run:

echo $PATH

This should give you information about where to put the new binary so the system knows where to look for it. The output should look similar to:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Then subsequently run:

which terraform

It should show you where the terraform binary is located and in most cases it matches one of the locations listed in PATH environment variable. Example:

/usr/local/bin/terraform

Then, unzip the file you downloaded and copy it over to the location of the old binary. Note that this will delete the old version.

There are better ways to handle multiple terraform versions though. One of those is using tfenv [1].

Another way to install (and override) versions of terraform is to follow the guide here [2] and use homebrew which is MacOS’ package manager, but in short the commands are:

brew tap hashicorp/tap
brew install hashicorp/tap/terraform

[1] https://github.com/tfutils/tfenv

[2] https://www.terraform.io/downloads

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading