hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.7k stars 9.55k forks source link

Custom plugins are not loaded when the filename is different #23958

Closed sharkwouter closed 4 years ago

sharkwouter commented 5 years ago

Terraform Version

Terraform v0.11.11

Terraform Configuration Files

provider "gridscale" {}

Debug Output

Here is the git with the output for the "terraform init" command: https://gist.github.com/sharkwouter/9db1cd20d1331b069bad90e5749f3c0f

Expected Behavior

I manually added a provider I'm working on to the ~/terraform.d/plugins directory. I was expecting terraform to be able to load it.

Actual Behavior

Terraform did not load the provider.

Steps to Reproduce

  1. Build the provider with: go build -o terraform-provider-gridscale-1.0.0-darwin-amd64
  2. Place the resulting "terraform-provider-gridscale-1.0.0-darwin-amd64" file in the ~/terraform.d/plugins directory.
  3. Create a configuration file which loads this provider in a new directory somewhere. See the example configuration.
  4. Run terraform init in the shell.

Additional Context

I've tested this with different compiles on Mac, Windows and Linux. I was able to reproduce this on all of them.

Changing the name of the provider file to terraform-provider-gridscale makes Terraform able to load the file. The following filenames would prevent the provider from being loaded:

I have also tried the putting the provider in the plugins/darwin_amd64 directory on Mac and plugins/windows_amd64 directory on Windows. This did not change the result.

So, to summarize the issue: Mac and Windows are not able to load a customer provider when the filename is not terraform-provider-providername. I was not expecting this to be the case, especially not when the filename is set when the provider is compiled.

References

sharkwouter commented 5 years ago

I just tested it again, the behaviour is the same on Linux.

sharkwouter commented 5 years ago

I finally found documentation about this: https://www.terraform.io/docs/extend/writing-custom-providers.html#building-the-plugin

apparentlymart commented 5 years ago

Hi @sharkwouter! Sorry the docs for this were not well-linked.

It looks like the user-facing docs for this are currently more detailed than the developer-facing docs. That set of docs is linked from the section you found, but only in a very subtle way (via the word "sideloaded", which is not a word we use anywhere else in the docs). I think there's room for improvement on the docs organization for this, so I'm going to reopen it and label it that way so that we can improve on this in the future.

clebio commented 5 years ago

hashicorp/terraform#16325 is related, yeah?

apparentlymart commented 4 years ago

Hi @paultyng!

The most recent meaning of this issue was representing possible improvements to the "Building the Plugin" section of the extend docs, which live in the hashicorp/terraform-website repository rather than in the hashicorp/terraform repository.

Did you move this issue back over here with a different intended change in mind? :thinking:

paultyng commented 4 years ago

The docs in this area could use some fixes potentially to make this clear, but the naming is called out. This may need updating again somewhat with the provider source changes coming in future versions (see https://github.com/hashicorp/terraform/pull/23843 among other issues), but we can revisit the docs once that is live.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.