Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform_required_providers: warn on provider.version #850

Merged
merged 2 commits into from
Jul 21, 2020

Conversation

bendrucker
Copy link
Member

This PR updates the required providers rule to warn when a provider block specifies a version attribute. While this does have the effect of constraining the installed provider version, users should be moving to required_providers because declaring a new copy of the provider is likely to have unexpected effects for child modules.

New logic is:

  • One issue is emitted for each provider name that is missing from required_providers. If multiple providers for a given name are declared, the first text range will be used.
  • One issue is emitted for each provider instance that has a version, regardless of whether it also appears in required_providers.

This means that users moving from earlier versions with of Terraform with provider "foo" { version = "" } in their configurations will see two issues that share an underlying fix. While it's possible to give more targeted messaging, there's a lot of possible cases here and keeping the rule simple seemed worthwhile.

Closes #839

@@ -10,7 +10,7 @@ rule "terraform_required_providers" {
}
```

## Example
## Examples

```hcl
provider "template" {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue message has been updated, so it would be nice to reflect it in the example output as well.

Copy link
Member

@wata727 wata727 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a suggestion, but it doesn't block merging this PR. Looks good!

@bendrucker bendrucker merged commit 9538f05 into master Jul 21, 2020
@bendrucker bendrucker deleted the deprecate-provider-version branch July 21, 2020 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

terraform_required_providers errs with multiple copies of the same provider
2 participants