Skip to content

Instantly share code, notes, and snippets.

@carljavier
Last active February 20, 2024 21:13
Show Gist options
  • Save carljavier/eca3b3a2fb8cadb6409d8d2fc7ecda23 to your computer and use it in GitHub Desktop.
Save carljavier/eca3b3a2fb8cadb6409d8d2fc7ecda23 to your computer and use it in GitHub Desktop.
M1 Macs and Terraform template provider (Depcreated) local build

M1 Macs and Terraform template provider (Deprecated) local build

If you have come across a Terraform repo and it is using https://registry.terraform.io/providers/hashicorp/template/latest or orignal sourcecode at https://github.com/hashicorp/terraform-provider-template and you are on an M1 MAC (Apple Silicon, darwin_arm64), you'll end up with the following error message when you do your terraform init locally on your M1 mac.

Initializing modules...
- tfe in ../..

Initializing the backend...

Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 3.60.0"...
- Finding hashicorp/template versions matching "~> 2.2.0"...
- Installing hashicorp/aws v3.60.0...
- Installed hashicorp/aws v3.60.0 (signed by HashiCorp)
╷
│ Error: Incompatible provider version
│ 
│ Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64.
│ 
│ Provider releases are separate from Terraform CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms supported.

How to Fix?

Refactor code

If you have the luxury to do so, refactor the used of the template provider and use templatefile() function. See the following recommendations.

Build the provider for M1

You can build the template provider from source code for M1 Macs.

Building the provider requires Go and understanding where Terraform looks for providers and plugins when you run terraform init.

Here's the rough series of commands:

ensure your $GOPATH is set in your terminal.

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

Then copy from $GOPATH/bin/terraform-provider-template to:

cp $GOPATH/bin/terraform-provider-template ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.1/darwin_arm64/

Inside your terraform workspace

rm .terraform.lock.hcl
terraform init

Initializing the backend...

Initializing provider plugins...
- Installing hashicorp/template v2.2.1...
- Installed hashicorp/template v2.2.1 (unauthenticated)

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment