hashicorp / terraform-provider-terraform

Terraform terraform provider
https://www.terraform.io/docs/providers/terraform/
Mozilla Public License 2.0
23 stars 22 forks source link

Terraform provider must be and cannot be version constrained #23

Closed bentterp closed 6 years ago

bentterp commented 6 years ago

Minor issue, I guess

Terraform Version

0.11.3

Affected Resource(s)

Please list the resources as a list, for example: provider.terraform

Terraform Configuration Files

provider "terraform" {
  version = "~> 1.0"
}

Output - with version constraint

terraform plan
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.terraform: this provider is built in to Terraform and so it does not support version constraints

Output - without version constraint

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...
- Downloading plugin for provider "aws" (1.9.0)...
- Downloading plugin for provider "template" (1.0.0)...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

* provider.terraform: version = "~> 0.1"

Expected Behavior

Either I should do version constraint or not, but there should at least be one way of not getting errors or warnings.

apparentlymart commented 6 years ago

Hi @bentterp! Sorry for this confusing behavior and thanks for reporting it.

I think you're seeing the same situation here as was discussed in hashicorp/terraform#17233. If so, the cause may be a separated version of this provider from when it was still a plugin still existing in .terraform/plugins, which apparently confuses the version resolving code into displaying a warning about the binary even though it's not actually being used.

For now the workaround would be to remove that file from .terraform/plugins. As discussed in that other issue, we plan to address this by detecting this particular situation and either cleaning it up automatically or generating a more specialized warning for it.

I'm going to close this just to consolidate discussion in hashicorp/terraform#17233. Thanks again for reporting this!