Terraform Intermittent error on Apple's M1

Viewed 396

When I run terraform plan, I expect to see a plan but instead I get

│ Error: Failed to load plugin schemas
│
│ 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
│ instantiate provider "registry.terraform.io/hashicorp/aws" to obtain schema: Unrecognized remote plugin message:
│
│ This usually means that the plugin is either invalid or simply
│ needs to be recompiled to support the latest protocol...

System is: arm64 m1 - Monterey - TFEnv - Terraform 1.1.9

2 Answers

Solution

Explanation

  1. An issue in Go runtime running amd64 M1 through Apple's Rosetta
  2. TFenv installed the amd64 version of Terraform instead of arm64.

Patch

Set the variable GODEBUG=asyncpreemptoff=1 by prepending it to the front of your terraform or adding it to your bash profile.

Fix

Make sure you are running the right build for your system.

➜ terraform version
Terraform v1.1.9
on darwin_arm64

If you are on an M1 and see darwin_amd64 when you run terraform version, try installing Terraform again.

With TFenv

TFENV_ARCH=arm64 tfenv install 1.2.4
tfenv use 1.2.4

Details

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

Just set the env var TFENV_ARCH to arm64 and re-install Terraform again using tfenv

Related