Skip to content

Feature Request: Add HCL/Terraform language support #310

@sachajw

Description

@sachajw

What would be involved

Looking at the existing language extractors in src/extraction/languages/, it seems like adding HCL would need:

  1. Tree-sitter grammars — tree-sitter-hcl and tree-sitter-terraform are available as WASM builds from the tree-sitter-hcl
    (https://github.com/Mitchell-Sandrock/tree-sitter-hcl) project
  2. Grammar registration in src/extraction/grammars.ts — map .hcl → hcl and .tf/.tfvars → terraform with WASM paths
  3. Language extractor (src/extraction/languages/hcl.ts) — HCL's primary construct is the block node, where named blocks follow the pattern:
    - resource "aws_instance" "web" { ... } — block type + labels
    - variable "name" { ... }
    - module "name" { ... }
    - data "type" "name" { ... }

The block name can be derived from concatenating the identifier and string_lit children of the block (e.g., resource.aws_instance.web).

Use cases

  • Navigate Terraform modules and their dependencies
  • Find all references to a specific resource across a large monorepo
  • Trace variable/output chains between modules
  • Search for resource types (aws_instance, azurerm_kubernetes_cluster, etc.)

Environment

  • CodeGraph v0.9.2
  • macOS (arm64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions