Skip to content

Add HCL parser support (.tf, .tfvars) #134

@josephismikhail

Description

@josephismikhail

Problem

Ix does not currently parse .tf or .tfvars files. HCL (HashiCorp Configuration Language) files are treated as unrecognized and excluded from analysis, meaning infrastructure definitions, resource configurations, and environment variables managed through Terraform are invisible to the system.

Proposed solution

Add an HCL parser that can identify and extract:

  • Resource blocks (e.g. resource "aws_s3_bucket" "my_bucket")
  • Data source blocks (e.g. data "aws_ami" "example")
  • Variable and output declarations
  • Module references (e.g. module "vpc")
  • Provider configurations
  • Locals blocks
  • *.tfvars variable assignments

Support the following file patterns: *.tf, *.tfvars

Why it matters

Terraform is the standard tool for infrastructure-as-code. In infrastructure-heavy repos, .tf files describe the entire cloud environment — networking, compute, storage, IAM, and more. Without parsing HCL, Ix cannot reason about infrastructure topology, trace how application code relates to the resources it depends on, or surface misconfigurations and dependencies across the stack. This is especially critical for a tool operating in an infrastructure context.

Merge requirements

Before this can be merged to main, the following must pass:

  • Tested on 3 repos
  • No regressions on existing parsers (ix map on a known TS/JS repo, verify counts unchanged)
  • Unit + smoke tests pass (npm test in ix-cli)
  • resource blocks ingested as entities with type and name labels
  • data source blocks ingested as entities
  • variable and output declarations ingested
  • module references ingested and linked to their source where possible
  • provider and locals blocks ingested
  • .tfvars variable assignments ingested and linked to their declared variable where possible
  • CONTAINS chains correctly: file → resource/module → nested block
  • ix text returns results with language: hcl
  • ix contains returns members for a known .tf file

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions