How gruntwork-io/terragrunt works
Terragrunt orchestrates Terraform/OpenTofu configurations: a user invokes a CLI command, configuration is parsed and units discovered, dependencies determine execution order, and units run with downloaded sources and an IaC engine. Results and outputs support downstream units. The repository also exposes catalog, MCP, remote-state bootstrap, and provider-cache capabilities. The README identifies the product but does not detail these subsystems; paths and relationships below use the supplied tree and sampled source, so unsampled wiring is left out.
Main entry points: commands CLI commands · run.go IaC command execution · runner Run orchestration · main.go CLI entry point
Components 22
CLI and tools
- CLI entry point
main.go - Command application
internal/cli/app.go - CLI commands
internal/cli/commands
Configuration and discovery
- HCL configuration
pkg/config - Unit discovery
internal/discovery - Unit components
internal/component
Orchestration and execution
- Run orchestration
internal/runner - Dependency queue
internal/queue/queue.go - Unit runner
internal/runner/unit_runner.go - IaC command execution
internal/runner/run/run.go - Source retrieval
internal/getter - Source content store
internal/cas
State and cloud integrations
- Remote state
internal/remotestate - Cloud backends
internal/remotestate/backend - Backend commands
internal/cli/commands/backend
Catalog and services
- Component catalog
internal/services/catalog - MCP server
internal/cli/commands/mcp - Provider cache server
internal/tf/cache/server.go
Other components
- Infrastructure engineer
- Terraform/OpenTofu
- Cloud APIs
- Engine plugin
Connections 21
- Infrastructure engineer → CLI entry point: invokes
- CLI entry point → Command application: starts
- Command application → CLI commands: dispatches
- CLI commands → HCL configuration: loads configuration
- HCL configuration → Unit discovery: provides configuration
- Unit discovery → Unit components: discovers units
- CLI commands → Run orchestration: starts runs
- Run orchestration → Dependency queue: schedules dependencies
- Run orchestration → Unit runner: dispatches units
- Unit runner → IaC command execution: executes unit
- IaC command execution → Source retrieval: retrieves source
- Source retrieval → Source content store: stores content
- IaC command execution → Terraform/OpenTofu: runs IaC command
- IaC command execution → Remote state: reads outputs
- Remote state → Cloud backends: uses backend
- Cloud backends → Cloud APIs: reads and writes state
- Backend commands → Cloud APIs: manages backend
- CLI commands → Component catalog: serves catalog
- CLI commands → MCP server: starts server
- CLI commands → Provider cache server: starts cache
- CLI commands → Engine plugin: launches plugin