Conversation
This fixes a bug introduced in 1879a39 in which initialising a module will fail if that module contains both a provider block and a module call using for_each.
apparentlymart
left a comment
There was a problem hiding this comment.
This looks good to me! I also tested it with some reconstructions of some test cases I was using when I originally worked on the other PR, just to satisfy myself that I remembered enough about what was going on here to understand why this change makes sense.
I have also started preparing a regression test case for this, but it ended up more annoying to integrate than I expected due to it being a concern that ends up crossing packages. If I get that working well I'll send it in as a separate PR so that we can get this landed sooner.
Thanks for diving in to this!
|
Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch. |
|
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. |
This fixes a bug introduced in #30639 in which initialising a module will fail if that module contains both a provider block and a module call using
for_each.This bug was introduced in https://github.com/hashicorp/terraform/pull/30639/files#diff-95e614048e1ba4ba7621e22ba67cfe5c8acd386e5540b8c92c267d2fd1b3d31eR31-R55 by removing a variable scoped to a
forloop (var nope) and instead overwritingnoProviderConfigRange. This meant that the error at https://github.com/hashicorp/terraform/pull/30639/files#diff-95e614048e1ba4ba7621e22ba67cfe5c8acd386e5540b8c92c267d2fd1b3d31eR181 would be triggered if the parent module contained a provider block, not the child.Fixes #31081
Test case
There are no tests in code for this behaviour. Highly recommend adding them as follow up. I manually tested this using the example below, kindly provided by @knbnnate.
main.tfbarren_child/main.tfgrandchild/main.tf