1

I am trying to build an AWS Custom Provider for Terraform.

  1. 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.

  2. 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.

nktsamba
  • 624
  • 8
  • 12
  • Did you get anywhere with this? I've also written my own provider and have a very similar problem `Error: Failed to instantiate provider "xxx" to obtain schema: fork/exec ......... permission denied` It works fine locally, but I cannot get it to run on Terraform Cloud – illusio May 20 '20 at 21:03
  • Yes, it was because I was using git lfs and currently Databricks does not support it. They have an internal feature request: 1137372123087938 to add support fot git lfs. To resolve it, I had to make sure that my compiled binary was not more that 100MB. – nktsamba May 22 '20 at 10:52
  • Happen with me also when I used helmfile provider. Very weird issue – Abdennour TOUMI Jul 18 '20 at 09:19

1 Answers1

1

There is something weird with the issue.

the first remark :

  • when I download the 3rdparty provider with curl, it does not work.

  • when I download it manually from the browser, it does work.

the second remark

  • when I download it with curl, the downloaded file has the following permissions/details:
-rwxr-xr-x  1 abdennour  staff  653 Jul 18 12:06 terraform-provider-helmfile
  • when I download it manually from the browser, I got :
-rwxr-xr-x@ 1 abdennour  staff  29358832 Jul 18 12:22 terraform-provider-helmfile

i can see here that curl does not download the full file because the file size is too small comparing with manual download.

Also, there is @ suffixing the file permissions when I download the file manually.

I don't know why that. but now it works

Abdennour TOUMI
  • 87,526
  • 38
  • 249
  • 254