created: 2023-07-07T05:21:22.166Z

Apple シリコン(m1マック) で terraform init が template v2.2.0~ エラーになる場合

terraform init でこんなエラーが出る場合。

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

$ terraform init
Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/template from the dependency lock file
- Reusing previous version of hashicorp/aws from the dependency lock file
- Installing hashicorp/aws v3.76.1...
- Installed hashicorp/aws v3.76.1 (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.
╵

解決法

環境変数をつけて install したバイナリだとエラーにならないので、terraform を入れ直す。

tfenv を使っている場合はこんな感じ。

$ TFENV_ARCH=amd64 tfenv install 1.0.5

参考

勉強の戦略――9割の「努力」をやめ、真に必要な一点に集中する
[ad] 勉強の戦略――9割の「努力」をやめ、真に必要な一点に集中する
岡 健作 (単行本)