-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Validate/plan throws "missing provider" errors when using aliases in module calls #28565
Comments
Hi @fatbasstard, Thanks for filing the issue. There are a couple slightly different problems here. Running validate in the child module is not expected to work, as it does not declare its own providers (which is issue #28490). The problem when running the commands from the root module here is that module2 does not have a local The resolution here is to be more explicit and pass in the desired provider to the first module as well
Just to be clear, the proposed configuration would not have worked consistently or correctly in older terraform releases, which is what these changes aimed to prevent. That unexpected default provider within the module was often a frequent cause of problems for users, but often worked silently until modules or provider configuration were changed. I think we may be able to improve the validation here a bit to point out the missing provider. I also want to see if we could allow the original config you proposed to do what (I think) was intended, which is to pass the default aws provider into the 3rd module as an alias even if that was never truly possible previously. |
Hi @jbardin , Thanks for the quick reply. This sample code is a simplified version of the way we use a lot of "shared modules" to encapsulate logic (an example: https://github.com/schubergphilis/terraform-aws-mcaf-s3). So if I understand it correctly: Validate does not work for standalone modules Always specify all the providers when calling a module providers = {
aws = aws.alias
} or providers = {
aws.alias = aws
} And that the default provider configuration is always passed along. So you say that it's better to ALWAYS pass all provider configurations explicitly? |
You are correct that it is only necessary to explicitly pass in a configuration for aliased providers, but the configuration shown here is somewhat of an edge case, where the first module needs an explicit configuration in order to pass it along to the second module. In other words, because the nested module requires a configuration, the first module does as well. I'm going to take a look at making this work internally, as I don't see anything technically wrong with allowing it, because it is not ambiguous that the default "aws" provider name within that module must be coming from the root module. |
Same issue here. My modules simply won't work now with tf15. Problem: I've upgraded from TF 0.14.10 to TF 0.15.1 and now my provider aliases don't seem to work. All of the providers are at the same version, including the AWS one I'm having an issue with. Terraform and provider versions:
I did apply the list of configuration_aliases to the terraform stanza, as was suggested in the upgrade documentation. It does not seem to help. Here is my configuration:
Result of a
What am I missing? |
Hi @aardvarq, What you see here is only a warning, so that should still work as it did before. The warning states that the |
I'm still getting the warning when I add the |
|
@aardvarq, the |
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. |
Terraform Version
Terraform Configuration Files
Simple setup, create the following setup:
Create the following 3 files
main.tf:
modules/module1/main.tf
modules/module2/main.tf
Pay attention to the commented (empty) provider configuration.
Expected Behavior
Expect the
terraform validate
all modules (root, module1 and module2) to return a:Success! The configuration is valid.
messageSince the AWS provider is specified in the required_providers, the empty provider configuration should be obsolete and the aliases are added to the
configuration_aliases
. (https://www.terraform.io/upgrade-guides/0-15.html#alternative-provider-configurations-within-modules)Actual Behavior
Terraform validate (but also the plan) in
module1
returns a:Terraform validate (but also the plan) in
module2
returns a:The Terraform validate in the root returns:
This error can be solved by adding (in this case by uncommenting) the empty provider configurations in
module1
andmodule2
.But then the following warning is thrown from
module2
:And the following warning is thrown from the root:
Steps to Reproduce
Construct the setup above. In short, in all modules run:
terraform init
terraform validate
/terraform plan
Additional Context
References
Somewhat related to the following issues:
terraform validate
against a module usingrequired_providers.[provider].configuration_aliases
#28567The text was updated successfully, but these errors were encountered: