Error while installing hashicorp/template v2.2.0

エラーログ

terraform initで下記エラー

│ Error: Failed to install provider
│
│ Error while installing hashicorp/template v2.2.0: the current package for registry.terraform.io/hashicorp/template 2.2.0 doesn't match any of the checksums previously recorded in
│ the dependency lock file; for more information: https://www.terraform.io/language/provider-checksum-verification
╵

利用環境がM1だった際に、チェックサムでコケる模様。
自分でgo buildが必要になる。

実行コマンド

Goの最新版をインストール。

> goenv install 1.19.0
> goenv global 1.19.0

build

> terraform -v
Terraform v1.3.0
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.32.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

> git clone https://github.com/hashicorp/terraform-provider-template.git
> cd terraform-provider-template
> go build .
> mkdir -p ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64
> mv terraform-provider-template ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64/terraform-provider-template_v2.2.0_x5

> rm .terraform.lock.hcl
> terraform init
> terraform init -upgrade

私の場合、initした際に

│ Error: Incompatible provider version
│
│ Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_amd64.
│
│ 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.

と表示されたのだけど、おそらくgoのインストールの仕方でbrewかgoenvかでGoのバイナリが変わるのかなと推測。
darwin_arm64でディレクトリ作っているけど、darwin_amd64でコピーする。
改めてterraform initしたら成功した。

> cd ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/
> cp -rp darwin_arm64 darwin_amd64

M1 macOSは難しいね。