Skip to content

fix(parser): evaluate module outputs (#116) - #117

Merged
andreacappelletti97 merged 1 commit into
mainfrom
fix/module-outputs
Oct 23, 2026
Merged

andreacappelletti97 merged 1 commit into
mainfrom
fix/module-outputs

Conversation

@andreacappelletti97

Copy link
Copy Markdown
Contributor

Fixes #116.

Expressions reading module.<name>.<output> never resolved. Nothing put module in the evaluation scope, and output blocks were never evaluated. So:

  • a count or for_each built from a module output dropped the whole block;
  • an attribute set from one was priced at the catalog default.

Change

  • Module calls are resolved before any resource is emitted. For each call, its instances are built, their own calls are resolved recursively, and their output blocks are evaluated in the module's scope.
  • The outputs go into the caller's scope as module.<name>: a tuple under count, and an object keyed by each.key under for_each. The caller's locals are then resolved again before the next call.
  • Calls are ordered so that one reading module.X (directly or through a local) comes after X. A cycle is broken in source order, and the parse still finishes.
  • Resources are emitted afterwards from the resolved tree, in the same order as before.
  • The parse budget still counts each module instance once.
  • Output blocks in .tf.json files are now translated (only value).

Verification

Expressions reading module.<name>.<output> never resolved, so a count or
for_each built from one dropped the block and an attribute set from one
fell back to the catalog default.

Module calls are now resolved before any resource is emitted: each call's
instances are built, their own calls resolved recursively, and their
output blocks evaluated in the module's scope. The outputs are added to
the caller's scope as module.<name> (a tuple under count, an object keyed
by each.key under for_each), and the caller's locals are resolved again,
before the next call. Calls are ordered so one that reads module.X, directly
or through a local, comes after X. Resources are emitted afterwards from the
resolved tree, in the same order as before.

Output blocks in Terraform JSON files are translated (value only).
@andreacappelletti97
andreacappelletti97 merged commit 5c7ed60 into main Oct 23, 2026
6 checks passed
@andreacappelletti97
andreacappelletti97 deleted the fix/module-outputs branch October 23, 2026 18:29
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.

Module outputs aren't evaluated: for_each over module.<name>.<output> drops the block

1 participant