Features¶
Cultivator provides practical features for automating Terragrunt workflows in CI.
Stack Discovery¶
Cultivator discovers stacks by walking the root directory and locating terragrunt.hcl files.
Scope Filters¶
Limit execution to specific areas:
--envfor environment filtering--include/--excludefor path filtering--tagsfor tag filtering (viacultivator:tagscomments)
Tag Filtering¶
Use tags to logically group stacks and selectively execute them.
Canonical format (recommended):
Compatibility format (still supported):
Tag parsing is case-insensitive and normalized to lowercase. Invalid tokens are ignored.
Usage with CLI:
# Execute only stacks with 'critical' tag
cultivator plan --root=live --tags=critical --non-interactive
# Execute stacks with either 'prod' or 'staging' tag
cultivator apply --root=live --tags=prod,staging --non-interactive --auto-approve
Usage in cultivator.yml:
Real-world example:
Your infrastructure might have:
live/
prod/
database/
terragrunt.hcl # cultivator:tags=critical,prod
api/
terragrunt.hcl # cultivator:tags=prod
cache/
terragrunt.hcl # cultivator:tags=optional,prod
dev/
database/
terragrunt.hcl # cultivator:tags=dev
Execute only critical production systems:
This will only execute live/prod/database/terragrunt.hcl.
Dependency-Aware Execution (DAG)¶
Cultivator automatically detects and respects Terragrunt dependency blocks. It builds a Directed Acyclic Graph (DAG) to determine the safest and most efficient execution order.
- Safe Ordering: If Module B depends on Module A, Cultivator ensures Module A completes successfully before starting Module B.
- Maximized Parallelism: Modules that do not depend on each other are executed concurrently, up to the defined
--parallelismlimit. - Cycle Detection: Cultivator validates your project structure and will error out if it detects circular dependencies, preventing infinite loops.
Magic Mode (Git Integration)¶
"Magic Mode" allows you to execute commands only on modules affected by code changes in a Pull Request or a specific commit range.
- Automatic Filtering: Use
--changed-onlyto let Cultivator query Git for modified files and automatically target only the relevant Terragrunt modules. - Smart Mapping: Changes to a file inside a module's directory (or its subdirectories) will trigger that module.
- Custom Base: Use
--base=main(or any branch/commit) to specify the reference point for change detection.
# In a PR branch, plan only what changed compared to main
cultivator plan --changed-only --base=main
Dry-Run Mode¶
Preview exactly what Cultivator would do without actually running any Terragrunt commands.
- Safety First: Use
--dry-runto see the list of discovered modules, the execution order determined by the DAG, and the exactterragruntcommands that would be invoked. - Verification: Ideal for verifying complex tag or path filters before applying changes to production.
Visualizing Dependencies¶
For complex projects, you can generate a visual representation of the execution order.
- Mermaid.js Output: Use the
--graphflag to output a Mermaid-compatible flowchart string. - Native Rendering: GitHub and GitLab automatically render these strings into visual diagrams when placed in Markdown files or Pull Request comments.
Parallel Execution¶
Run stacks concurrently with a configurable worker pool:
Configurable Log Levels¶
Control Cultivator's own log verbosity via the CULTIVATOR_LOG_LEVEL environment variable:
Accepted values: debug, info, warning, error. Default: info.
Terragrunt output is always printed in full, regardless of this setting.
Environment Verification (Doctor)¶
Before running plans or applies, verify that your environment is correctly configured:
The doctor command checks:
- Terragrunt is installed and available in
PATH - Config file is loadable (when passed with
--config) - Root directory exists and is a valid directory
This is useful as a pre-flight check in CI pipelines before running plan or apply.
Stateless Operation¶
Cultivator does not manage state or backends. Terragrunt and Terraform/OpenTofu handle state as usual.
Cross-Platform Support¶
- GitHub Actions
- GitLab CI
- Local execution
See User Guide for how to use these features.