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

Backport of Validate duplicate provider local names in required_providers into v1.2 #31251

Conversation

teamterraform
Copy link
Contributor

Backport

This PR is auto-generated from #31218 to be assessed for backporting due to the inclusion of the label 1.2-backport.

The below text is copied from the body of the original PR.


Adding multiple local names for the same provider type in required_providers was not prevented, which can lead to ambiguous behavior in Terraform. Providers are always located via the provider's fully qualified name (even using the full name as a map key in many places), so duplicate local names cannot be differentiated. This can lead terraform to non-deterministically configure the incorrect provider in some cases.

Because it is currently possible that a configuration with providers which themselves do not need explicit configuration may have been working with duplicates, we cannot turn these into errors. Adding multiple entries for the same provider now results in a warning like so:

│ Warning: Duplicate required provider
...
│
│ Provider hashicorp/null with the local name "dupe" was previously required as "null". A provider
│ can only be required once within required_providers.

We can also check for the situation where a user required a provider by a name different from the default, but attempted to configure that provider via the default local name. This can help prevent the case where a provider configuration may apparently not always be taking effect within a module. The warning here is worded slightly differently:

│ Warning: Duplicate required provider
...
│
│ Provider hashicorp/null with the local name "dupe" was implicitly required via a configuration
│ block as "null". Make sure the provider configuration block name matches the name used in
│ required_providers.

fixes #31196

@teamterraform teamterraform force-pushed the backport/jbardin/validate-provider-local-names/willingly-deep-pony branch from 96c0c6e to 7279d60 Compare June 15, 2022 17:52
@jbardin jbardin merged commit b174c96 into v1.2 Jun 15, 2022
@jbardin jbardin deleted the backport/jbardin/validate-provider-local-names/willingly-deep-pony branch June 15, 2022 18:19
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants