Skip to content

Instantly share code, notes, and snippets.

@abuxton
Forked from straubt1/Terraform on Mac M1.md
Created August 3, 2022 10:42
Show Gist options
  • Save abuxton/7d915c1f22599ee6c277913e0f76d0bd to your computer and use it in GitHub Desktop.
Save abuxton/7d915c1f22599ee6c277913e0f76d0bd to your computer and use it in GitHub Desktop.
Notes to install Terraform on M1

Installing the amd64 version of Terraform on Mac with M1

Not all Terraform providers are built for arm64.

One solution here is to install Terraform as amd64 which can be easily done from the downloads page.

However, for those who are using and switching between versions of Terraform often, a more streamlined approach is desirable.

Enter asdf.

Install asdf

Update ~/.zshrc to include:

plugins=(asdf)

Install asdf with git:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf

Reload your shell

. ~/.zshrc
asdf info

Install Terraform

Install asdf Terraform profile with:

asdf plugin-add terraform https://github.com/asdf-community/asdf-hashicorp.git

Install terraform with:

# Override to install amd64, install specific version (can be "latest")
export TF_VERSION="latest"
export ASDF_HASHICORP_OVERWRITE_ARCH="amd64"

# install and set globally
asdf install terraform ${TF_VERSION}
asdf global terraform ${TF_VERSION}

# show version for good measure
terraform -v

Note: This can also go into your .zshrc file for future use on a specific version

terraform_install () {
  export TF_VERSION=$1
  export ASDF_HASHICORP_OVERWRITE_ARCH="amd64"

  # install and set globally
  asdf install terraform ${TF_VERSION}
  asdf global terraform ${TF_VERSION}

  # terraform version for good measure
  terraform -v
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment