Advanced Dependency Visualization with Input Variables¶
Feature: Show Explicit Input Variables in Dependency Graph¶
Overview¶
The --show-inputs flag enables advanced dependency visualization that shows explicit input variables passed between Terragrunt stacks, not just module dependencies.
Usage¶
Basic Dependency Graph (Default)¶
Output: Standard dependency graph showing which modules depend on each other.
Advanced Graph with Input Variables¶
Output: Enhanced dependency graph including: - Module dependencies - External dependencies (outside current directory) - Input variable references between stacks
How It Works¶
Default Mode¶
Uses terragrunt dag graph command:
This is an alias for:
Advanced Mode (--show-inputs)¶
Uses explicit terragrunt list command with full flags:
Key Differences:
- --dependencies: Includes dependency information in output
- --external: Discovers external dependencies (input variables from other stacks)
- --format=dot: Outputs in GraphViz DOT format for visualization
Examples¶
Example 1: Basic Dependencies¶
Shows:
Example 2: With Input Variables¶
Shows:
vpc (outputs: vpc_id, subnet_ids)
└─ security-groups (inputs: vpc_id from vpc)
└─ ec2-instances (inputs: vpc_id from vpc, sg_id from security-groups)
└─ rds (inputs: subnet_ids from vpc)
Use Cases¶
1. Understanding Cross-Stack Dependencies¶
Useful for: - Identifying blast radius of changes - Understanding data flow between stacks - Planning refactoring efforts
2. Debugging Dependency Issues¶
Helps identify: - Missing output values - Circular dependencies - Incorrect dependency declarations
3. Documentation Generation¶
# Generate comprehensive dependency documentation
thothctl check iac -type deps --show-inputs > dependencies.dot
dot -Tpng dependencies.dot > dependencies.png
Technical Details¶
Terragrunt Commands Used¶
Default (--show-inputs not set):
Advanced (--show-inputs set):
What Gets Discovered¶
With --show-inputs, Terragrunt discovers:
- Direct Dependencies: Modules explicitly declared in
dependencyblocks - External Dependencies: Dependencies outside the current working directory
- Input Variables: Variables passed via
dependencyoutputs - Transitive Dependencies: Dependencies of dependencies
Output Format¶
Both modes output GraphViz DOT format, which can be:
- Displayed in terminal (ASCII tree visualization)
- Converted to images:
Configuration¶
Terragrunt Configuration Example¶
# Stack A: VPC
# stacks/vpc/terragrunt.hcl
terraform {
source = "../../modules/vpc"
}
inputs = {
cidr_block = "10.0.0.0/16"
}
# Stack B: Security Groups (depends on VPC)
# stacks/security-groups/terragrunt.hcl
dependency "vpc" {
config_path = "../vpc"
}
inputs = {
vpc_id = dependency.vpc.outputs.vpc_id # ← This is shown with --show-inputs
}
Comparison¶
| Feature | Default | --show-inputs |
|---|---|---|
| Command | dag graph |
list --format=dot --dependencies --external |
| Shows modules | ✅ Yes | ✅ Yes |
| Shows dependencies | ✅ Yes | ✅ Yes |
| Shows external deps | ✅ Yes | ✅ Yes |
| Shows input variables | ❌ No | ✅ Yes |
| Shows output values | ❌ No | ✅ Yes |
| Performance | Fast | Slightly slower (more discovery) |
Best Practices¶
-
Use default mode for quick checks:
-
Use --show-inputs for detailed analysis:
-
Combine with recursive flag:
-
Generate documentation:
Troubleshooting¶
Issue: No external dependencies shown¶
Solution: Ensure your Terragrunt configurations use dependency blocks:
Issue: Graph is too complex¶
Solution: Use filtering or focus on specific stacks:
Issue: Command is slow¶
Solution: The --show-inputs flag requires more discovery. For quick checks, use default mode:
Related Commands¶
thothctl check iac -type blast-radius- Assess change impactthothctl check iac -type tfplan- Analyze Terraform plansthothctl inventory iac- Create infrastructure inventory