3
votes

I am quite new to terraform and golang, I am trying to implement a custom provider, for a POC, to check if we can leverage terraform for our own use.

I was able to write and build the golang provider according to this video and some GitHub examples.

I created a go workspace an set the $GOPATH to default, $HOME/go.

Terraform packages is installed at $GOPATH/src/github/hashicorp.

Terraform binary is installed at $HOME/dev and specified at the $PATH.

according to the video, I created the provider package at /terraform/builtin/providers/mycustomprovider

And "go build"ed the package to $GOPATH/bin

Once I tried to 'terraform plan' I get the following:

provider.incapsula: no suitable version installed

version requirements: "(any version)"

versions installed: none

I added the custom provider binary to terraform.d/plugins and tried to run 'terraform plan' again.

now I am getting the following error:

Error: Error asking for user input: 1 error(s) occurred: * provider.incapsula: fork/exec ~/.terraform.d/plugins/darwin_amd64/terraform-provider-incapsula: permission denied

I tried to chmod to 666 and chown the binary file, but with no luck, I am still getting the same error.

I tried to look for this kind of issue but couldn't find any reference.

I would appreciate any assistance.

Thanks!

1
can you active debug mode, and try again, anything helpful? TF_LOG=DEBUG terraform planBMW

1 Answers

5
votes

The provider binary needs execute permissions, so try using 755 instead of 666. Also if the binary isn't somewhere in your $PATH, you generally need to run `terraform init -plugin-dir=.terraform/plugins/darwin_amd64" so terraform picks up the provider and updates the md5 lock file.

So try chmod 755 <wherever the provider is> and if it's still not working, use terraform init with the -plugin-dir argument pointing to the plugin directory (your provider should already be in there).