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

Implicitly passed default providers are not resolved to parent provider keys in JSON output #30513

Closed
nozaq opened this issue Feb 13, 2022 · 4 comments · Fixed by #30525
Closed
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue

Comments

@nozaq
Copy link
Contributor

nozaq commented Feb 13, 2022

Terraform Version

This issue is related to #30138, which is merged but not released yet.

Tested with the current main branch, specifically this tree.

Terraform Configuration Files

This repo contains a complete example.

Below diagram summarizes the setup.
overview

The project contains three layers of module call hierarchy, i.e. Root module > module.foo > module.bar, and each module contains one null_resource resource.
Root module has two providers null and null.second, and passes null.second to module.foo. module.foo calls module.bar without explicitly passing the provider, but module.bar ends up using null.second since module.foo's default null provider is null.second.

Expected Behavior

provider_config_key for all resources point to null.second in JSON output.

Actual Behavior

module.foo.module.bar.level3 points to module.foo.module.bar:null while level1 and module.foo.level2 point to null.second.

This is the actual JSON output from terraform show -json.

Steps to Reproduce

  1. terraform init
  2. terraform plan -out temp.out
  3. terraform show -json temp.out > plan.json
  4. Open plan.json

Additional Context

#30138 intended to resolve provider mappings up to the module call tree, but it seems that the current implementation only considers explicitly passed provider configurations.
This could be fixed by resolving implicitly passed default providers as well.

References

@nozaq nozaq added bug new new issue not yet triaged labels Feb 13, 2022
@nozaq nozaq changed the title Implicitly passed default providers are not resolved to parent providers Implicitly passed default providers are not resolved to parent provider keys in JSON output Feb 13, 2022
@alisdair alisdair added confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Feb 14, 2022
@alisdair
Copy link
Member

Thanks for the report! I was able to confirm this issue, and added another example configuration to your reproduction case which verified this further for me.

At first glance I don't see an obvious way to fix this. If you do, and you'd like to submit a PR, I'll happily review it. Otherwise I'll try to find time to revisit this shortly, hopefully before Terraform 1.2 is released.

@alisdair alisdair self-assigned this Feb 14, 2022
@nozaq
Copy link
Contributor Author

nozaq commented Feb 15, 2022

@alisdair Thank you for qucikly confirming the issue! I've merged your reproduction case.

At first glance I don't see an obvious way to fix this. If you do, and you'd like to submit a PR, I'll happily review it.

Sure, I'll send a PR for review in few days. Just looked through the code and there seems to be a few ways to try.

@nozaq
Copy link
Contributor Author

nozaq commented Feb 15, 2022

@alisdair Just submitted #30525. Please let me know if you have any comments or suggestions!

@github-actions
Copy link

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.
If you have found a problem that seems similar to this, 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 Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants