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

Fix providers that depend on output of module #2925

Merged
merged 2 commits into from Mar 5, 2024

Conversation

aliscott
Copy link
Member

@aliscott aliscott commented Mar 4, 2024

This fixes the case where a provider block depends on an output of a module and then that provider is passed to the module and used in a data resource.

Before this would create a circular dependency in the graph evaluator because we were treating providers passed into modules as an edge in the graph. Instead now we just maintain a reference to providers when a module is created and then evaluate them and add them to the context at various points in the evaluation process:

  1. Before we evaluate a data block, since for special data attributes we might need the provider on the context (e.g. aws_current_region)
  2. When we are closing out the module, since after this we collect the default tags values from the module to add to any of the resources.

We could improve this in two ways, but this would be a bigger refactor at the moment:

  1. Maintaining a global context for the evaluated providers, instead of adding them to each modules evaluation context.
  2. Only evaluating the provider blocks if we need to, instead of for all data resources.

@aliscott aliscott self-assigned this Mar 4, 2024
`providers` attributes in module calls should not create edges, because the provider can
depend on outputs from the module which can then create circular dependencies.
@aliscott aliscott force-pushed the fix/providers-depend-on-data branch from 5d36258 to d611eb6 Compare March 5, 2024 10:35
@aliscott aliscott changed the title Fix providers that depend on data Fix providers that depend on output of module Mar 5, 2024
@aliscott aliscott marked this pull request as ready for review March 5, 2024 10:48
@aliscott aliscott requested a review from tim775 March 5, 2024 10:48
@aliscott aliscott merged commit a964da9 into master Mar 5, 2024
8 of 10 checks passed
@aliscott aliscott deleted the fix/providers-depend-on-data branch March 5, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants