Skip to content

Release 0.56.2: module call scoping (#294, #295), Terragrunt engine match - #296

Merged
patrickchugh merged 6 commits into
mainfrom
fix/issue-294
Nov 18, 2026
Merged

patrickchugh merged 6 commits into
mainfrom
fix/issue-294

Conversation

@patrickchugh

@patrickchugh patrickchugh commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Release 0.56.2. Closes #294. Closes #295.

1. Scope plain references to their own module instance (#294)

A plain reference such as aws_s3_bucket.this, written inside a module, matched every node whose name contained it. When one module folder is called several times, a resource in one call linked to the same resource in every other call; on the reporter's roots the edge count went from 425 to 3,838 and the draw stalled.

_find_matching_resources (modules/graphmaker.py) now keeps only matches in the source resource's module instance, for_each key included (module.per_team["a"]), or top-level matches for a top-level source. It falls back to all matches when the instance has none, so references passed in through module variables still resolve. References that already name a module are not scoped.

2. Give every module call its .tf attributes (#295)

A module folder's .tf files are parsed once. When the folder was called several times, only the first call got the attributes, and for_each/count instances never found them. Those resources lost the references links are built from.

  • prefix_module_names() copies the folder's resources for every call (most specific folder only). The old partial duplication in fileparser is removed.
  • merge_metadata() looks resources up without module instance keys.
  • The per-resource module name drops the instance key, so module variables are found.

3. Terragrunt uses TerraVision's engine binary

Terragrunt defaults to OpenTofu when tofu is on PATH, while --engine auto prefers terraform, so with both installed reading the plan failed ("plan files cannot be transferred between different Terraform versions"). _tg_env() now sets TG_TF_PATH / TERRAGRUNT_TFPATH to TerraVision's binary unless the user set one. Docs updated.

4. CI and dependency fixes

  • ubuntu-latest moved to Ubuntu 26.04, which ships neato's layout engine as a separate package (libgvplugin-neato-layout8). Preflight stopped every CLI run, so CI failed on main too. Both workflows that install Graphviz now add the plugin when the package exists.
  • opentelemetry-api 1.45.1 → 1.45.2 for CVE-2026-126360 (flagged by pip-audit).

Expected JSON changes (approved by the maintainer)

tests/json/expected-nested-modules.json:

New replay fixture multi-call-module-tfdata.json (the #294 example) with expected-multi-call-module.json.

Version

0.56.1 → 0.56.2; MCP pin moved with scripts/set_versions.py --pin. Plugin version bump follows once PyPI serves 0.56.2.

Tests

New: tests/test_module_scope_matching.py, tests/test_module_calls_metadata.py, TestTgEnv. Full suite locally on the rebased branch (with #290, #291, #293 merged): 2,939 passed.

Follow-up

#298: Terraform graph edges are dropped for for_each/count module instances (pre-existing, deferred).

A plain reference such as aws_s3_bucket.this, written inside a module,
matched every node whose name contained it. When one module folder was
called several times, a resource in one call linked to the same resource
in every other call; on large roots the extra edges stalled the draw.

_find_matching_resources now keeps only matches in the source's module
instance (for_each key included), or top-level matches for a top-level
source. It falls back to all matches when the instance has none, so
references passed in through module variables still resolve. References
that already name a module are not scoped.

expected-nested-modules.json: removed the cross-call links this bug
produced (s3_access_logs versioning, encryption and lifecycle to the
documents, frontend, guides and images buckets; mkhan-test ECR lifecycle
policy to the pgadmin repository). Each resource keeps the link to its
own bucket or repository. Approved by the maintainer.
Terragrunt defaults to OpenTofu when tofu is on PATH, while TerraVision's
--engine auto prefers terraform. With both installed, Terragrunt wrote
the plan with OpenTofu and TerraVision's terraform show failed: "plan
files cannot be transferred between different Terraform versions".

_tg_env now sets TG_TF_PATH (and TERRAGRUNT_TFPATH for Terragrunt before
0.73) to TerraVision's engine binary, unless the user already set one.
A module folder's .tf files are parsed once. When the folder was called
several times, prefix_module_names() gave the resources to the first
call only, and for_each/count instances (module.per_team["a"]) never
found them because their addresses carry a key the files lack. Those
resources lost the references links are built from, so most of them
were drawn unconnected.

- prefix_module_names() copies the folder's resources for every call,
  matching only the most specific module folder. The partial duplication
  in fileparser (first resource only) is removed.
- merge_metadata() looks resources up without module instance keys
  (without_module_keys).
- The per-resource module name drops the instance key, so module
  variables are found; older debug files are handled too.

New replay fixture multi-call-module-tfdata.json (the issue's example)
with expected-multi-call-module.json.

expected-nested-modules.json, approved by the maintainer: 27 links added
and none removed. 20 for the S3 module calls' sub-resources to their own
bucket, 1 for pgadmin's ECR lifecycle policy to its repository, 6 for the
VPC to the for_each VPC endpoints. 5 security group rule nodes in later
calls of the shared sg module gain the ~1 suffix the first call already
had; they have no links.
@patrickchugh patrickchugh changed the title Scope plain references to their own module instance (#294) Release 0.56.2: module call scoping (#294, #295), Terragrunt engine match Nov 18, 2026
ubuntu-latest moved to 26.04, where neato's layout engine is a separate
package (libgvplugin-neato-layout8) that graphviz does not pull in.
TerraVision's preflight check then stops every run, so every test that
calls the CLI failed, on main as well as on pull requests.
Flagged by pip-audit; 1.45.2 is the fixed version.
@sonarqubecloud

Copy link
Copy Markdown

@patrickchugh
patrickchugh merged commit 8282de0 into main Nov 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant