I am trying to build an AWS Custom Provider for Terraform.
The provider is at this repository: https://github.com/lyle-nel/terraform-provider-aws and I have followed all the instructions on the readme to create the provider binary.
I have the followed the instructions on how to build and configure a custom provider for Terraform cloud found here: https://www.terraform.io/docs/cloud/run/install-software.html#custom-and-community-providers
So basically, I put my binary in the following directory structure for Terraform Cloud to pick it up: terraform.d/plugins/linux_amd64/.
But when I run my repo with my compiled binary, I get this error on Terraform cloud:
Error: Failed to instantiate provider "aws" to obtain schema: fork/exec /terraform/aws_tf/terraform.d/plugins/linux_amd64/terraform-provider-aws: exec format error
I googled a bit and I found that I have to statically compile the binary and specify the Architecture, and I did so with this command:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -ldflags '-w -extldflags "-static"'
And if I run file to get the details of the binary, it shows it as statically linked file terraform-provider-aws: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
but on Terraform Cloud, it still comes back with the same error.
I built the binary first on Linux Mint 19.3 which is the OS I am using, and when that didn't work, I created an Ubuntu 18.04 VM and tried it there [because the docs say Terraform Cloud runs on Ubuntu so I thought it would make a difference], but still no luck.
If there is anyone who has done this before, or who knows where I am getting it wrong, please help me out. I am losing my mind here.