Skip to content

Terraform/HCL config values aren't linked into the cross-repo config-key graph (unlike Kubernetes) #412

Description

@dsh971

Problem

Gortex already resolves cross-repo configuration coupling for Kubernetes manifests — internal/parser/languages/kubernetes.go extracts container.env[], envFrom, and valueFrom into KindConfigKey nodes connected via EdgeUsesEnv edges, the same id-space that os.Getenv() reads in application code resolve against. So a config value set in a K8s manifest in one repo is already matched, cross-repo, to the code that consumes it.

Terraform/HCL doesn't get the same treatment. internal/parser/languages/hcl.go parses resource/variable/output/module/data blocks into graph nodes, but reference edges are explicitly scoped to "the file's directory — the Terraform module boundary." A Terraform-defined value never reaches the shared config graph.

This matters because Terraform frequently sets the environment values that Kubernetes-native YAML would otherwise set directly — ECS task definition environment entries, Lambda environment blocks, or Terraform-managed kubernetes_config_map/kubernetes_secret resources. Any of those currently fall into the same blind spot Kubernetes manifests already solved.

Example

Repo A's Terraform defines a variable (or an ECS/Lambda environment entry) like MAX_BATCH_SIZE with a default value. Repo B's application code reads it via os.Getenv("MAX_BATCH_SIZE"), with no import or shared package linking the two repos. Today, gortex contracts has no way to surface that link — the same value set via a Kubernetes manifest instead would already be caught.

Proposed scope

  • Extend the HCL extractor so variable/output blocks representing runtime config, and specific resource types that set service environment values (ECS task definitions, Lambda environment blocks, kubernetes_config_map/kubernetes_secret via the Terraform Kubernetes/Helm providers), emit the same KindConfigKey node + EdgeUsesEnv edge that Kubernetes manifests already produce.
  • No changes to the existing contract-matcher expected — feeding it this new input should be enough for cross-repo matching to work the same way it already does for env vars/K8s.
  • Static parsing only, no terraform plan/state evaluation — consistent with how every other input is handled.
  • Existing Terraform reference resolution (module-scoped resource/variable/output edges) stays untouched — this is additive.

Questions for maintainers

  • Is this something you'd want, and does the proposed scope (ECS/Lambda/K8s-provider resources as a starting set) match how you'd shape it, or would you prefer a different starting point?
  • Single PR, or staged (variables/outputs first, provider-specific resource types as follow-ups)?

Happy to put together a PR with test coverage (same-repo match, cross-repo match, and a regression check against existing K8s/env-var matching) if this is a direction you'd want

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions