terraform-provider-aws: Random failures during terraform plan/apply on M1 + Rosetta (darwin_amd64)

I am not able to find out why executing terraform plan/apply will fail on the random bases. This behaviour happen regardless of the complexity of the project. I tried using local and S3 backends and same result.

I installed terraform and aws cli using brew, I even run brew doctor to verify if something was broken and no issues.

I originally raised a Terraform CLI BUG, But seems like this bug is most likely related to the AWS provider.

Terraform Version

Terraform v1.1.4
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.73.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

AWS CLI Version

aws-cli/2.4.12 Python/3.9.10 Darwin/21.2.0 source/x86_64 prompt/off

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">=3.70.0"
    }
  }
}

provider "aws" {
  profile = var.aws_iam_profile
  region  = var.deployment_region
}

resource "aws_s3_bucket" "prod_web" {
  bucket = "superman-batman-yoyo"
  acl    = "private"

  versioning {
    enabled = true
  }
  server_side_encryption_configuration {
    rule {
      apply_server_side_encryption_by_default {
        sse_algorithm = "AES256"
      }
    }
  }
}

resource "aws_s3_bucket_public_access_block" "prod_web" {
  bucket = aws_s3_bucket.prod_web.id

  block_public_acls       = true
  block_public_policy     = true
  ignore_public_acls      = true
  restrict_public_buckets = true
}

Debug Output

2022-01-12T15:24:29.056+1100 [ERROR] plugin.(*GRPCProvider).ValidateProviderConfig: error="rpc error: code = Canceled desc = context canceled"
2022-01-12T15:24:29.057+1100 [ERROR] vertex "provider[\"registry.terraform.io/hashicorp/aws\"]" error: Request cancelled
2022-01-13T11:03:10.772+1100 [ERROR] vertex "provider[\"registry.terraform.io/hashicorp/aws\"]" error: Unrecognized remote plugin message: 

This usually means that the plugin is either invalid or simply
needs to be recompiled to support the latest protocol.

Expected Behavior

Stop crashing!

Actual Behavior

Need to run multiple times terraform plan/terraform apply to deploy the infrastructure šŸ˜•

Steps to Reproduce

  1. terraform plan
  2. terraform apply

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 12
  • Comments: 23

Most upvoted comments

Looks like i was actually running the amd64 version of Terraform, not the arm64. Installed arm64 version and ran a new terraform init, have not seen issues since. Could be an issue with rosetta / go.

āžœ  ~ terraform --version
Terraform v1.1.3
on darwin_amd64
āžœ  ~ tfenv uninstall 1.1.3
Uninstall Terraform v1.1.3
Terraform v1.1.3 is successfully uninstalled
āžœ  ~ TFENV_ARCH=arm64 tfenv install 1.1.3
Installing Terraform v1.1.3
Installation of terraform v1.1.3 successful. To make this your default version, run 'tfenv use 1.1.3'
āžœ  ~ terraform --version
Terraform v1.1.3
on darwin_arm64

I am on

 Model Name:	MacBook Pro
  Model Identifier:	MacBookPro18,2
  Chip:	Apple M1 Max

and can confirm this happens very often with hashicorp/aws v3.70.0 and hashicorp/aws v3.63.0

Im closing this, as there is a resolution to the issue (can confirm it works for me as well) is to install a terraform binary that fits the architecture of you workstation. both tfenv and brew have relevant flags for this, feel free to look at their docs.

additional resource:

If you installed using brew using. Rosetta terminal. Brew will install all the packages using amd64. As far as I know you can not have dual brew (amd64. Arm) šŸ˜•(. Most Likely you need to uninstall brew and all the existent packages, then install brew using a non Rosetta terminal.

@KhimairaCrypto I’m not able to amd version and install arm can you please help me on how to do that?

I’m new to mac.

I ran the below commands.but still amd version is not getting removed.

āžœ ~ terraform --version

Terraform v1.1.3

on darwin_amd64

āžœ ~ tfenv uninstall 1.1.3

Uninstall Terraform v1.1.3

@kimeirik-crayon according to Terraform official way is

brew tap hashicorp/tap
brew install hashicorp/tap/terraform

I do not have version issues with any of my projects and there is alway a unique terraform version (latest) in my build server.

The question is it fully supported on Rosetta?