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 passing default providers through modules into v0.15 #28615

Merged

Conversation

teamterraform
Copy link
Contributor

Backport

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

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


Add validation for the local side of the providers map assignments in module calls. If these did not actually correspond to a configuration during runtime, the user would be presented with a missing provider error with the assumed address of the provider, but no indication how to configure that address. We can detect these during validation, and present a much more precise error

╷
│ Warning: No configuration passed in for provider aws in module.mod1
│
│   on mod1/main.tf line 15, in module "mod2":
│   15:     aws.local = aws
│
│ Provider aws is referenced within module.mod1, but no configuration has been supplied.
│ Add a provider named aws to the providers map for module.mod1 in the root module.

It was also assumed that inherited providers could be referenced within modules, which is understandable because resources effectively do the same. This inheritance does not work in module calls however, because the provider is looked up in the next child module, one level removed from the inherited provider. Rather than re-work inheritance to account for this edge case, we can direct users to create a more explicit configuration by declaring the name within the module, so that we can follow up with the above recommendation if no configuration is presented.

│ Warning: Provider aws is undefined
│
│   on mod1/main.tf line 15, in module "mod2":
│   15:     aws.local = aws
│
│ No provider named aws has been declared in module.mod1.
│ If you wish to refer to the aws provider within the module, add a provider configuration, 
│ or an entry in the required_providers block.

Fixes #28565

@teamterraform teamterraform force-pushed the backport/jbardin/providers-in-modules/monthly-whole-peacock branch from 23fb17e to 504bd9a Compare May 5, 2021 13:07
@teamterraform teamterraform requested a review from jbardin May 5, 2021 13:07
@jbardin jbardin merged commit c29c75e into v0.15 May 5, 2021
@jbardin jbardin deleted the backport/jbardin/providers-in-modules/monthly-whole-peacock branch May 5, 2021 13:15
@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2021

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 Jun 5, 2021
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.

2 participants