Terraform: Terraform plan for a custom provider giving "no suitable version installed"

Created on 19 Sep 2017  ยท  16Comments  ยท  Source: hashicorp/terraform

Hello

I am trying to write a custom terraform provider. I ran "go get" and "go build" on the provider which generated the executable. I moved the executable to /usr/local/Cellar/terraform/0.10.6/bin/. So now, I have the terraform executable and the provider executable in the same place. When I run the terraform init, I see that the provider is initialized successfully.

Terraform Version : 0.10.6

Initializing provider plugins...

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

terraform plan output

Plugin reinitialization required. Please run "terraform init".
Reason: Could not satisfy plugin requirements.

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

1 error(s) occurred:

* provider.test: no suitable version installed
  version requirements: "(any version)"
  versions installed: none

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints from each module, run "terraform providers".

error satisfying plugin requirements

Can someone suggest what might be going wrong here?

bug cli

Most helpful comment

Following solution work with my problem,
Try to first, delete .terraform directory form current folder then try to run terraform init and terraform plan
rm -rf .terraform
terraform init
terraform plan
the reason for this error is when you copy all configuration file from the source folder to the destination folder then it finds the problem with .terraform in the destination directory

All 16 comments

Are you naming your provider correctly as per here? https://www.hashicorp.com/blog/hashicorp-terraform-provider-versioning/

eg terraform-provider-NAME_vX.Y.Z

(Shameless self plug: if you install your provider through homebrew on mac, I have a little script which will handle "installing" the correctly into ~/.terraform.d/plugins/darwin_amd64/ )

@drewsonne Yes. My provider is called "terraform-provider-test" and my Terraform plan has

provider "test" {
Name: ....
Id: ...
}
Also, when my executable is called "terraform-provider-test_v1.0.0", it still does the same thing.

no suitable version installed
  version requirements: "(any version)"
  versions installed: none

Hi @anuiq! Sorry things aren't working as expected here.

If you run terraform with the environment variable TF_LOG=debug set, it should print out a lot of additional debug information which includes, near the top, the information about where Terraform looked for plugins and which plugins it found. If you can capture that log output and put it in a gist and link to it here then that may give me some more info to understand what Terraform is doing here.

@apparentlymart @drewsonne I got this to work. I ran a go build in the directory where my terraform plan and go files are.
My directory structure
terraform-provider-sysdig
--main.go
--provider.go
--resource_test.go
--test.tf

When I run a go build in this directory, a terraform executable is generated in the same folder.

terraform-provider-sysdig
--main.go
--provider.go
--resource_test.go
--test.tf
--terraform-provider-test (executable)

Now, I was copying that executable over to the place where my terraform executable was since that is how I ran other providers, but in this case, that approach did not work. I had to run terraform init using the plugin-dir option

terraform init -plugin-dir=.

This ran my plan. I am wondering if there is no default plugin-dir for terraform custom providers.
So, in short, when we are writing custom providers, terraform init needs the exact location of the executable and that doesnt need to be in the same location as the terraform executable.

In my setup, I have my executables in ~/.terraform.d/plugins/${GOOS}_${GOARCH}/

Hi @anuiq!

I'm glad you found an approach that works for you. Putting the executable in the same directory as terraform _should_ have worked, so it seems like something strange is going on which I am happy to try to dig into some more if you'd like, but if you're happy with the new approach you found then no worries!

Hey @apparentlymart

What works ?
If I move the custom provider executable to this location
/usr/local/Cellar/terraform/0.10.6/bin/terraform.d/plugins/darwin_amd64/
The terraform executable is in
/usr/local/Cellar/terraform/0.10.6/bin/
and I run a terraform init with this

terraform init -plugin-dir="/usr/local/Cellar/terraform/0.10.6/bin/terraform.d/plugins/darwin_amd64/"

What does not work?
if both the terraform executable and the custom provider executable are in this location
/usr/local/Cellar/terraform/0.10.6/bin/
Why did I think the above should work?
Because this is how I ran my code when I was working with other providers, for example, dns provider.

I am still wondering what the default location for plugin-dir is? What location does terraform init look in when it wants to run an executable?

Thank you

Hi @anuiq,

The terraform.d/plugins directory applies as a subdirectory of the current working directory when you run Terraform. When placing plugins in the same directory as terraform itself, no subdirectories are needed, so you'd have the following files:

/usr/local/Cellar/terraform/0.10.6/bin/terraform
/usr/local/Cellar/terraform/0.10.6/bin/terraform-provider-test-v0.0.1

Since /usr/local/Cellar is managed by homebrew, it may be best not to modify the contents of this directory manually. As an alternative, you can put the plugin in your home directory:

~/.terraform.d/plugins/darwin_amd64/terraform-provider-test-v0.0.1

Terraform searches this directory in addition to the directory where the terraform binary is found.


With that said, since you are currently _developing_ a provider, I suggest a different approach for more convenient workflow:

  • Copy /usr/local/Cellar/terraform/0.10.6/bin/terraform to $GOPATH/bin/terraform
  • Make sure that $GOPATH/bin is in your PATH environment variable _before_ the homebrew bin directory, so that running terraform will run the copy in your GOPATH.
  • Make sure your source directory for your plugin is named terraform-provider-test. For example, you might place it at $GOPATH/src/github.com/anuiq/terraform-provider-test .
  • Build your plugin using go install github.com/anuiq/terraform-provider-test (assuming the example path from the previous step), which will create $GOPATH/bin/terraform-provider-test
  • Now you can run terraform init and it should find the binary you just built.

This approach has the advantage of removing the need to keep copying around the plugin binaries each time you rebuild.

You can also set the following environment variable in your terminal to remove the need to re-run terraform init each time you rebuild:

export TF_SKIP_PROVIDER_VERIFY=1

Once you've finished development and want to install the provider "for real", you can then copy $GOPATH/bin/terraform-provider-test to ~/.terraform.d/plugins/darwin_amd64/terraform-provider-test-v0.0.1 so that your homebrew-installed Terraform can find it.

Thank you @apparentlymart
This is great information. I am sure this workflow makes things simpler.

Following solution work with my problem,
Try to first, delete .terraform directory form current folder then try to run terraform init and terraform plan
rm -rf .terraform
terraform init
terraform plan
the reason for this error is when you copy all configuration file from the source folder to the destination folder then it finds the problem with .terraform in the destination directory

hello sorry to bump this old topic but i have a similar issue. I am trying to create 2-3 instances so when i plan it some times gives me the details and some times i get the error message

but when i tried to validate i get the below error message
c:terraform>terraform validate

Error: 1 error(s) occurred:

  • provider.aws: no suitable version installed
    version requirements: "(any version)"
    versions installed: none

can some one guide me what do i need to do

On a macOS

Hi, regardless on where and how I tried to start the rancher2 provider is not working:
I have it here:

ll /usr/local/Cellar/terraform/0.11.11/bin/
- terraform
- terraform-provider-rancher2_darwin-amd64

and here:

~/.terraform.d/plugins/darwin_amd64/terraform-provider-rancher2_darwin-amd64

and I use it like this:

terraform init -get-plugins=false -plugin-dir="~/.terraform.d/plugins/darwin_amd64/"

or like this:

 TF_SKIP_PROVIDER_VERIFY=1  TF_SKIP_PROVIDER_VERIFY=1

the only message I get is this:

Initializing provider plugins...

Missing required providers.

The following provider constraints are not met by the currently-installed
provider plugins:

* rancher2 (any version)

Terraform can automatically download and install plugins to meet the given
constraints, but this step was skipped due to the use of -get-plugins=false
and/or -plugin-dir on the command line.

If automatic installation is not possible or desirable in your environment,
you may manually install plugins by downloading a suitable distribution package
and placing the plugin's executable file in one of the directories given in
by -plugin-dir on the command line, or in the following directory if custom
plugin directories are not set:
    terraform.d/plugins/darwin_amd64

my rancher.tf looks like this:

provider "rancher2" {
  api_url = "https://my-rancher/v3" //
  secret_key = "some secret"
  access_key = "token-gg" //
}

NOTE: same rancher tf works with those credentials if I make a provider "rancher"
Need help. maybe is just some small thingy.
Thanks!

It worked when I replaced '~/.terraform.d/plugins/darwin_amd64/' with "$HOME/.terraform.d/plugins/darwin_amd64"

terraform init fixed the issue for me.

terraform init and then terraform apply.
the issue will resolve.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rjinski picture rjinski  ยท  3Comments

rkulagowski picture rkulagowski  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

c4milo picture c4milo  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments