Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get `terraform init` to run on my Apple Silicon Macbook Pro for the Google Provider?

When I run terraform init for my Google Cloud Platform project on my Apple Silicon macbook pro I get this error.

Provider registry.terraform.io/hashicorp/google v3.57.0 does not have a package available for your current platform, darwin_arm64.

How can I work around this? I thought that the Rosetta2 emulator would check this box, but alas...

like image 920
reka18 Avatar asked Sep 01 '25 18:09

reka18


2 Answers

Build Terraform from scratch by using the tfenv package, which can build a specific version adapted to the platform architecture.

I ran the following to install a version that works under my M1 Macbook (version 1.3.3 in this case):

brew uninstall terraform
brew install tfenv
TFENV_ARCH=amd64 tfenv install 1.3.3
tfenv use 1.3.3
like image 59
arvymetal Avatar answered Sep 04 '25 14:09

arvymetal


Thanks for this repo: https://github.com/kreuzwerker/m1-terraform-provider-helper. This will remove the overhead of building and compiling from us.

Usage:

brew install kreuzwerker/taps/m1-terraform-provider-helper
m1-terraform-provider-helper activate # (In case you have not activated the helper)
m1-terraform-provider-helper install hashicorp/template -v v2.2.0 # Install and compile

This will compile the provider for our arm_64 in the location:

~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64

For this to be working, these are my findings:-

  • Your Terraform version should be at least >= 1.0.2
  • You should delete the older checksums of the requested provider [template in my case] from the .terraform.lock.hcl
    • or try running m1-terraform-provider-helper lockfile upgrade which finds and updates these checksums
  • Please change your provider and version that you need to be installed in the terraform code.

Go ahead now !!!

like image 35
Kishor U Avatar answered Sep 04 '25 13:09

Kishor U