I'm trying to install the RKE provider as part of the Rancher AWS quickstart. The Terraform documentation says that plugins should be installed at ~/.terraform.d/plugins
. The RKE documentation says that the plugin should be installed at ~/terraform.d/plugins/<your_platform>
.
Trying to reconcile the conflicting information, I tried copying the binary to all of the following locations, but Terraform never saw any of them:
~/.terraform.d/plugins/terraform-provider-rke
~/.terraform.d/plugins/rke
~/.terraform.d/plugins/darwin_amd64/terraform-provider-rke
~/.terraform.d/plugins/darwin_amd64/rke
~/terraform.d/plugins/terraform-provider-rke
~/terraform.d/plugins/rke
~/terraform.d/plugins/darwin_amd64/terraform-provider-rke
~/terraform.d/plugins/darwin_amd64/rke
In each case, when I ran terraform init
, I got the following error:
Provider "rke" not available for installation.
A provider named "rke" could not be found in the Terraform Registry.
This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.
In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
terraform.d/plugins/darwin_amd64
Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".
Error: no provider exists with the given name
As a last resort, I could use terraform init -plugin-dir=<something>
. But then Terraform doesn't see any of the automatically downloaded plugins, and I have to manually install everything.
Is there some path variable that's missing, or some other naming convention that I am failing to follow?
Terraform CLI finds and installs providers when initializing a working directory. It can automatically download providers from a Terraform registry, or load them from a local mirror or cache. If you are using a persistent working directory, you must reinitialize whenever you change a configuration's providers.
The Terraform Registry is the main directory of publicly available Terraform providers, and hosts providers for most major infrastructure platforms. Each provider has its own documentation, describing its resource types and their arguments.
When Terraform encounters an error in your configuration, it will report an error including line numbers and the type of issue found in the configuration. In this tutorial, you will clone a repository with a broken Terraform configuration to deploy an EC2 instance and underlying networking.
terraform fmt only parses your HCL for interpolation errors or malformed resource definitions, which is why you should use terraform validate after formatting your configuration to check your configuration in the context of the providers' expectations. Initialize your Terraform directory to download the providers that your configuration requires.
It turns out that the error message didn't tell the whole story. Terraform was finding the provider, but it didn't think it was a new enough version.
According to Terraform's documentation, the provider needs to be named as terraform-provider-<NAME>_vX.Y.Z
. The documentation for the RKE provider said that the file should be called terraform-provider-rke
(no version number).
In a comment in the Terraform source code for plugin discovery, it says that this versionless format is supported for reverse compatibility. However, Terraform interprets the version to be v0.0.0
.
When I ran terraform plan
after the failed terraform init
, it gave me a more informative error message:
Error: provider.rke: no suitable version installed
version requirements: "0.14.1"
versions installed: "0.0.0"
That version is presumably a requirement from another provider that depends on the RKE provider.
I went back and manually downloaded that exact version from the Github repo and copied it into the plugins directory with the name terraform-provider-rke_v0.14.1
. It worked!
So there you go. When in doubt, look at the source code. Now to submit an issue report to Rancher, telling them to update their documentation. :-)
For Windows Users on Corporate Firewall, where direct download of provider zip file is not permitted.
terraform init -plugin-dir .
Directory structure:
aws_v3.37.0_x5.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With