Skip to content

Bug: Terraform registry modules with a //subdir path or a private registry host never get a latest version #618

Closed

Description

@vibgrate-team

Context

scanTerraform in src/core-open/scanners/terraform-scanner.ts only looks up a module's latest version when its source splits into exactly three parts (namespace/name/provider). Two very common registry forms fall through and always show drift unknown:

module "endpoints" {
  source  = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"
  version = "5.8.1"
}

module "net" {
  source  = "app.terraform.io/acme/network/aws"
  version = "2.3.0"
}

What to do

  • Strip a //subdir suffix before splitting the source; the subdirectory does not change which registry module is versioned.
  • Recognise an optional leading registry hostname (registry.terraform.io/, app.terraform.io/, other hosts) and keep it out of namespace/name/provider.
  • Only query the public registry for public-registry modules; leave private-host modules at unknown rather than guessing.
  • Add unit tests.

Acceptance

  • The first example is looked up as terraform-aws-modules/vpc/aws and gets a real drift value.
  • registry.terraform.io/hashicorp/consul/aws resolves the same as hashicorp/consul/aws.
  • A private-host module never triggers a public-registry lookup.

Activity

  1. added
    bug
    on Nov 10, 2026
  2. vibgrate-team commented on Nov 10, 2026

    @vibgrate-team
    ContributorAuthor

    Confirmed against src/core-open/scanners/terraform-scanner.ts: the registry lookup only runs when source.split('/') gives exactly three parts (around line 263), so terraform-aws-modules/vpc/aws//modules/vpc-endpoints (five parts) and app.terraform.io/acme/network/aws (four) both fall through to unknown.

    A small parseRegistrySource(source) helper is the cleanest fix: drop everything from // onward, then if the first segment contains a . (or : for a port) treat it as the host. Return { host, namespace, name, provider } and only call the public registry when host is empty or registry.terraform.io. Keep the original source string as the row name so output stays recognisable. Table-driven tests over the three forms in the acceptance list will cover it.

  3. added a commit that references this issue on Nov 11, 2026
    be6ec95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions