A caller adds for_each to a module block to create one copy of a shared module per team. terraform init now fails, reporting that the module cannot be used with for_each because it contains its own provider configuration. What must change for the caller's design to work?
Select an answer to reveal the explanation.
Short Explanation
Here's the rule you need: if a module brings its own provider block, it can't be multiplied. Strip the provider out, let the caller hand it in, and for_each works fine.
Full Explanation
Provider configurations belong in the root module and are passed down to child modules. A module that contains its own provider block is a legacy pattern, and Terraform documents that such a module is not compatible with the for_each, count and depends_on arguments on the module block, which is exactly the error the caller hits. The fix is in the module: delete the provider block, declare the provider's source and minimum version in required_providers, and let the caller pass its provider configuration, implicitly for the default configuration or explicitly with the providers argument when aliases are involved. Once the module no longer configures providers, the caller can expand it with for_each per team. Switching to count does not help, because count carries the same incompatibility. Adding an alias inside the module still leaves a provider configuration inside the module, so the restriction still applies. The depends_on argument is also among the meta-arguments that cannot be used with such a module, and ordering was never the problem. Exam caveat: if the per-team copies need different accounts or regions, define aliased provider configurations in the root and pass them through the providers argument. Operational check: after the change, run terraform init and a plan with three keys and confirm three instances of the module's resources are proposed.