【问题标题】:How can I get `terraform init` to run on my Apple M1 Macbook for Azure platform?如何让 `terraform init` 在我的 Apple M1 Macbook for Azure 平台上运行?
【发布时间】:2022-01-27 06:25:39
【问题描述】:
在我的 Macbook 上运行 terraform init 时出现以下错误。有人可以帮忙吗?
Provider registry.terraform.io/hashicorp/template v2.2.0 没有适用于您当前平台 darwin_arm64 的软件包。
我的 terraform 版本是 1.1.4。
【问题讨论】:
标签:
azure
terraform
cloud
provider
apple-m1
【解决方案1】:
在 Apple 推出其新的 Apple Silicon 平台之前的一段时间,hashicorp/template 插件已经过时(取而代之的是 the built-in templatefile function)。该提供商唯一可用的版本是在该平台存在之前发布的版本。
要推进 Apple Silicon 硬件,您将有两个主要选择:
-
理想情况下,计划从过时的提供程序迁移并改用内置模板功能。该功能内置于 Terraform 本身,因此不需要任何外部提供程序即可工作。它也比旧的template_file 数据源更强大,因为templatefile 可以接受任何类型的模板变量,而template_file 只支持字符串。
-
如果您还没有准备好从该提供程序迁移出去,那么您可能更愿意在 Rosetta 2 仿真下使用 darwin_amd64 版本的 Terraform。如果您为 darwin_amd64 使用 Terraform CLI 版本,那么它将依次安装 darwin_amd64 提供程序包,因此您将能够使用模板提供程序的最终版本 v2.2.0。
Rosetta 2 并未正式支持 Terraform,因此其效果如何取决于 Apple 的模拟层的完整程度,但它有望作为一种短期解决方法,直到您准备好停止使用这个过时的提供程序.