Apple M1 上的 Terraform 间歇性错误

Eze*_*eno 5 terraform terraform-provider-aws apple-m1

当我跑步时terraform plan,我希望看到一个计划,但我却得到了

\n
\xe2\x94\x82 Error: Failed to load plugin schemas\n\xe2\x94\x82\n\xe2\x94\x82 Error while loading schemas for plugin components: Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/aws: failed to\n\xe2\x94\x82 instantiate provider "registry.terraform.io/hashicorp/aws" to obtain schema: Unrecognized remote plugin message:\n\xe2\x94\x82\n\xe2\x94\x82 This usually means that the plugin is either invalid or simply\n\xe2\x94\x82 needs to be recompiled to support the latest protocol...\n
Run Code Online (Sandbox Code Playgroud)\n

系统是:arm64 m1 - Monterey - TFEnv - Terraform 1.1.9

\n

Eze*_*eno 10

解决方案

\n

解释

\n
    \n
  1. 通过 Apple Rosetta 运行 amd64 M1 的 Go 运行时出现问题
  2. \n
  3. TFenv安装了 amd64 版本的 Terraform,而不是 arm64。
  4. \n
\n

修补

\n

GODEBUG=asyncpreemptoff=1通过将变量添加到 terraform 的前面或将其添加到 bash 配置文件中来设置变量。

\n

使固定

\n

确保您正在运行适合您的系统的正确版本。

\n
\xe2\x9e\x9c terraform version\nTerraform v1.1.9\non darwin_arm64\n
Run Code Online (Sandbox Code Playgroud)\n

如果您使用 M1,看看darwin_amd64您何时跑步terraform version,请尝试再次安装 Terraform。

\n

与 TFenv

\n
TFENV_ARCH=arm64 tfenv install 1.2.4\ntfenv use 1.2.4\n
Run Code Online (Sandbox Code Playgroud)\n

细节

\n
    \n
  1. https://github.com/hashicorp/terraform-provider-aws/issues/23850
  2. \n
  3. https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/
  4. \n
\n