Skip to content

fix(terraform): read installed module versions from modules.json - #655

Closed
vibgrate-team wants to merge 1 commit into
mainfrom
cursor/terraform-modules-json-c720
Closed

vibgrate-team wants to merge 1 commit into
mainfrom
cursor/terraform-modules-json-c720

Conversation

@vibgrate-team

Copy link
Copy Markdown
Contributor

Summary

Registry module constraints such as version = "~> 5.0" were reported with resolvedVersion: null. Drift was then computed from the lowest version the range allows. Providers already take an exact version from .terraform.lock.hcl; modules have no lock file.

After terraform init or tofu init, the installed version of each module is in .terraform/modules/modules.json next to the configuration being scanned. When that file is present, a registry module row now uses Modules[].Version as resolvedVersion, and drift is computed from that version.

Matching prefers the module call name (Key). Nested calls are parent.child and are not applied to a different root call. Source must be the same registry module: registry.terraform.io/ and a //subdir suffix are ignored, and a private registry host is kept. Git, local, and other non-registry sources are skipped. A missing, unreadable, or malformed file is ignored, so the previous constraint-only result stays.

Related issues

Closes #621

Checklist

  • pnpm test passes
  • pnpm lint is clean
  • pnpm typecheck is clean
  • Docs updated (README / DOCS / ARCHITECTURE) where behavior changed
  • Determinism preserved — identical input still produces identical graph.json / report output (content-hashed IDs, stable sorts; no time, randomness, or filesystem-order dependence)
  • No proprietary or internal references — public, Apache-2.0 content only
  • Commits use Conventional Commits and are signed off (git commit -s, DCO)

Notes for reviewers

Tests cover an installed 5.8.1 against ~> 5.0, unchanged output when modules.json is absent, malformed JSON, a non-registry Source with the same key, and two calls of one module resolved to different versions.

Open in Web Open in Cursor 

Registry module constraints were scored from the lowest version the
range allows, because modules have no lock file. When
.terraform/modules/modules.json is present, use its Version as
resolvedVersion for the matching registry call. A missing or malformed
file leaves the constraint-only result.

Closes #621

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: vibgrate-team <vibgrate-team@users.noreply.github.com>
@vibgrate-team

Copy link
Copy Markdown
Contributor Author

Closing this so #621 stays with @hamid-digitalmarketer, who claimed it on #144 before this PR was opened.

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.

Enhancement: read resolved Terraform module versions from .terraform/modules/modules.json

2 participants