-
Notifications
You must be signed in to change notification settings - Fork 581
Description
Description
When using generate_projects with terragrunt: true and root_dir, Digger fails to parse Terragrunt configurations that use standard Terragrunt functions like find_in_parent_folders() and HCL expressions like ${dirname(...)}.
These are standard Terragrunt patterns used in virtually every Terragrunt project following Gruntwork's recommended structure.
Configuration
digger.yml:
generate_projects:
blocks:
- include: "live/**"
terragrunt: true
root_dir: "./"
workflow: default
include_patterns:
- "modules/**"
- "root.hcl"Sample terragrunt.hcl (standard Terragrunt pattern):
include "root" {
path = find_in_parent_folders("root.hcl")
}
terraform {
source = "${dirname(find_in_parent_folders("root.hcl"))}//modules/networking"
}
inputs = {
vpc_cidr = "10.10.0.0/16"
}Error
time=2026-03-19T14:58:14.603Z level=INFO msg="generating terragrunt projects for block" blockName="" rootDir=./
time=2026-03-19T14:58:14.603Z level=INFO msg="hydrating config with terragrunt projects" workingDir=./ filterPaths=[.]
time=2026-03-19T14:58:14.654Z level=ERROR msg="failed to parse terragrunt configuration" error="Variables not allowed: Variables may not be used here. (and 8 other messages)"
time=2026-03-19T14:58:14.654Z level=ERROR msg="failed to hydrate config with terragrunt" error="failed to autogenerate digger_config, error during parse: Variables not allowed: Variables may not be used here. (and 8 other messages)" blockName=""
time=2026-03-19T14:58:14.654Z level=ERROR msg="project generation failed" error="failed to autogenerate digger_config, error during parse: Variables not allowed: Variables may not be used here. (and 8 other messages)"
Exit code: 4
Expected Behavior
generate_projects should be able to discover Terragrunt projects by scanning for terragrunt.hcl files under the include glob pattern without needing to fully parse the HCL contents. The directory structure alone is sufficient to generate the project list — Digger doesn't need to evaluate Terragrunt functions to know which directories contain projects.
Root Cause
Digger's internal HCL parser attempts to evaluate the Terragrunt configuration files but doesn't understand Terragrunt-specific functions (find_in_parent_folders, read_terragrunt_config, etc.) and HCL interpolation expressions (${dirname(...)}). These are core Terragrunt features used in virtually every project.
Suggested Fix
For generate_projects with terragrunt: true, Digger could:
- Use directory-based discovery — scan for
terragrunt.hclfiles matching theincludepattern and derive project names from directory paths, without parsing the HCL contents - Shell out to Terragrunt — use
terragrunt output-module-groupsor similar Terragrunt CLI commands that handle the parsing natively - Use a lenient parser — skip evaluation of functions/expressions and just detect that a valid
terragrunt.hclexists
Workaround
Currently we generate digger.yml with explicit projects: entries using a shell script that runs find live -name terragrunt.hcl and constructs the project list. This works but requires a generation step (pre-commit hook or CI task) to keep digger.yml in sync with the directory structure.
Environment
- Digger action:
diggerhq/digger@vLatest - OpenTofu: 1.11.0
- Terragrunt: 1.0.0-rc3
- Runner:
ubuntu-latest