macOS: Developer notes — Update Terraform from v0.12 to v1.0.3

Chandan Singh
2 min readJul 31, 2021

Upgrade Terraform 0.12 to version 0.13

# Check Terraform version
terraform -v
# Update Homebrew
brew update
# Install version 0.13
brew install terraform@0.13
# If you need to have terraform@0.13 first in your PATH, run:
echo 'export PATH="/usr/local/opt/terraform@0.13/bin:$PATH"' >> ~/.zshrc
# Reload shell
source ~/.zshrc
# Change your working directory where your terraform files are
cd <your folder>
# Run command to auto upgrade to 0.13
terraform 0.13upgrade
# Look at your changes in source code editor
# Use your version control system to review the proposed changes, make any necessary adjustments, and then commit.

Remove version information from the old AWS configuration

provider "aws" {
version = "~> 2.65" # <- Remove the version info
region = "us-east-1"
...
}

Add version information from the old AWS configuration

required_providers {  archive = {
source = "hashicorp/archive"
version = "~> 2.2.0" # Add version information
}
aws = {
source = "hashicorp/aws"
version = "~> 3.0" # Add version information
}
}

Run the following command:

terraform init -reconfigure

You should see:

# Terraform has been successfully initialized!

Run

terraform plan
terraform apply

Read https://www.terraform.io/upgrade-guides/0-13.html for any error or special cases.

Upgrade to Terraform 0.14

Download and install Terraform 0.14

curl https://releases.hashicorp.com/terraform/0.14.11/terraform_0.14.11_darwin_amd64.zip -o terraform_0.14.11.zipunzip -oul terraform_0.14.11.zipmkdir -p /usr/local/opt/terraform@0.14/bin
cp ./terraform /usr/local/opt/terraform@0.14/bin/terraform
echo 'export PATH="/usr/local/opt/terraform@0.14/bin:$PATH"' >> ~/.zshrcterraform -v# You should see 'Terraform v0.14.11'

Run

terraform init# Output:
# Terraform has been successfully initialized!
terraform planterraform apply

Upgrade to Terraform 1.0.3

You can upgrade from 0.14 to 1.0.3 directly. Please still consider the notes from the Terraform v0.15 upgrade guide. If you are affected by the notes in that upgrade guide, you will still need to take the steps described there but you can do so as part of upgrading to v1.0, without any need for an intermediate step of running Terraform v0.15.

brew install terraformterraform -v# Output: Terraform v1.0.3

If you see error for 0.14 folder, run rm -rf /usr/local/opt/tarrform@0.14/bin

Run

terraform init# Output:
# Terraform has been successfully initialized!
terraform plan

No changes. Your infrastructure matches the configuration.

Your configuration already matches the changes detected above. If you’d like to update the Terraform state to match, create and apply a refresh-only plan:

To apply refresh only, run

terraform apply -refresh-only# accept the changes with a `yes`

You should have the latest version of Terraform infrastructure if you have reached until this stage.

--

--