Karishma Kohli
Karishma Kohli

Reputation: 21

How can I get `terraform init` to run on my Apple M1 Macbook for Azure platform?

I am getting the following error when running terraform init on my Macbook. Can someone please help?

Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64.

My terraform is version is 1.1.4.

Upvotes: 2

Views: 6461

Answers (3)

Isanka Wijerathne
Isanka Wijerathne

Reputation: 4146

For me building "hashicorp/template" from the source was the solution. I was using terragrunt.

git clone https://github.com/hashicorp/terraform-provider-template.git
cd terraform-provider-template
go build 

move the binary to terraform plugins directory. You can create the directory if the plugin's directory does not exist.

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

Set execution permission to the terraform-provider-template binary file.

chmod +x ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64/terraform-provider-template

terraform init or terragrunt init from your project folder.

Upvotes: 1

arvymetal
arvymetal

Reputation: 3244

I solved it by using the tfenv package, which can build a specific Terraform 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 my case):

brew uninstall terraform
brew install tfenv
TFENV_ARCH=amd64 tfenv install 1.3.3
tfenv use 1.3.3

Upvotes: 8

Martin Atkins
Martin Atkins

Reputation: 74045

The hashicorp/template plugin became obsolete (in favor of the built-in templatefile function) some time before Apple introduced its new Apple Silicon platform. The only releases available for that provider are those which were published before that platform existed.

To move forward on Apple Silicon hardware, you'll have two main options:

  • Ideally, plan to migrate away from the obsolete provider and use the built-in template function instead. That function is built in to Terraform itself, and so doesn't need any external provider to work. It is also more capable than the old template_file data source in that templatefile can accept template variables of any type, whereas template_file only supports strings.

  • If you are not yet ready to migrate away from that provider then you may instead prefer to use the darwin_amd64 version of Terraform under Rosetta 2 emulation. If you use a Terraform CLI release for darwin_amd64 then it will in turn install darwin_amd64 provider packages, and so you'll be able to use the final release v2.2.0 of the template provider.

    Terraform is not officially supported under Rosetta 2, so how well this will work will depend on how complete Apple's emulation layer is, but it can hopefully serve as a short-term workaround until you're ready to stop using this obsolete provider.

Upvotes: 5

Related Questions