Specialist Terragrunt Ally
Streamline your workflow with this expert, terragrunt, specialist, mastering. Includes structured workflows, validation checks, and reusable patterns for devops infrastructure.
Terragrunt Ally
Your specialized agent for managing complex Terraform deployments with Terragrunt, enabling DRY infrastructure code, multi-account orchestration, and dependency management across environments.
When to Use This Agent
Choose Terragrunt Ally when:
- Managing multi-account, multi-region Terraform deployments with Terragrunt
- Reducing Terraform code duplication using Terragrunt's DRY patterns
- Orchestrating dependencies between Terraform modules across environments
- Implementing Terragrunt configurations for enterprise landing zones
- Migrating from raw Terraform to Terragrunt for better organization
Consider alternatives when:
- You have a simple single-account Terraform setup β use a standard Terraform agent
- You prefer Terraform Cloud/Enterprise for orchestration β use a Terraform engineer agent
- You need infrastructure design without IaC tooling β use a cloud architect agent
Quick Start
# .claude/agents/terragrunt-ally.yml name: Terragrunt Ally model: claude-sonnet tools: - Read - Write - Edit - Bash - Glob - Grep description: Terragrunt specialist for DRY infrastructure code, multi-account orchestration, and dependency management
Example invocation:
claude "Set up a Terragrunt project structure for a multi-account AWS deployment with shared networking, per-account EKS clusters, and centralized monitoring"
Core Concepts
Terragrunt Project Structure
infrastructure-live/
βββ terragrunt.hcl # Root config (remote state, provider generation)
βββ _envcommon/ # Shared variable definitions
β βββ networking.hcl
β βββ compute.hcl
β βββ database.hcl
βββ dev/
β βββ account.hcl # Account-specific vars
β βββ us-east-1/
β β βββ region.hcl
β β βββ vpc/terragrunt.hcl
β β βββ eks/terragrunt.hcl
β β βββ rds/terragrunt.hcl
β βββ us-west-2/
β βββ ...
βββ staging/
β βββ ...
βββ prod/
βββ ...
Key Terragrunt Features
| Feature | Purpose | Example |
|---|---|---|
include | Inherit parent configs | include "root" { path = find_in_parent_folders() } |
dependency | Declare inter-module dependencies | dependency "vpc" { config_path = "../vpc" } |
generate | Auto-generate provider/backend blocks | Generate provider.tf with account creds |
inputs | Pass variables to Terraform modules | inputs = { vpc_id = dependency.vpc.outputs.vpc_id } |
run_all | Orchestrate multiple modules together | terragrunt run-all apply |
Configuration
| Parameter | Description | Default |
|---|---|---|
source_base | Base path for Terraform modules | git::[email protected]:org/modules.git |
state_bucket_pattern | State bucket naming pattern | {account}-{region}-terraform-state |
account_structure | Account layout (flat, ou-based) | ou-based |
lock_table | DynamoDB table for state locking | terraform-locks |
terragrunt_version | Terragrunt CLI version | >= 0.55.0 |
Best Practices
-
Use
find_in_parent_folders()to keep configs DRY. Define remote state, provider generation, and common variables in the rootterragrunt.hcl, then useincludeblocks in leaf configs. Each leaf config should only contain what's unique to that specific deployment. -
Declare explicit dependencies between modules. Use
dependencyblocks to tell Terragrunt which modules must apply before others. This enables saferun-all applycommands that respect ordering β networking before compute, compute before monitoring. -
Use
_envcommonfor shared module configurations. Extract shared variable definitions and module sources into_envcommon/*.hclfiles. Each environment'sterragrunt.hclthen merges these common configs with environment-specific overrides. -
Pin module source versions per environment. Use different
reftags for dev, staging, and prod so module upgrades flow through environments sequentially. Dev gets the latest, prod gets the proven version. -
Use
mock_outputsfor plan-time dependency resolution. When runningterragrunt planbefore dependencies are applied,mock_outputsprovides placeholder values so the plan can complete. This is essential for CI pipelines that plan all modules in parallel.
Common Issues
run-all apply fails partway through the dependency chain. When one module fails, dependent modules can't proceed. Use --terragrunt-non-interactive with --terragrunt-ignore-dependency-errors carefully in CI, or better, fix the failing module first. Run run-all plan before apply to catch errors early.
Circular dependencies between modules cause deadlocks. Terragrunt can't resolve circular dependency blocks. Restructure your modules to break the cycle β often by extracting shared resources (like VPC) into a separate module that both sides depend on instead of depending on each other.
State bucket doesn't exist for a new account/region. Terragrunt can auto-create state buckets with remote_state { ... config = { ... } } and generate blocks, but this requires the initial credentials to have bucket-creation permissions. Use a bootstrap script that creates the state bucket and DynamoDB lock table before running Terragrunt for the first time.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
API Endpoint Builder
Agent that scaffolds complete REST API endpoints with controller, service, route, types, and tests. Supports Express, Fastify, and NestJS.
Documentation Auto-Generator
Agent that reads your codebase and generates comprehensive documentation including API docs, architecture guides, and setup instructions.
Ai Ethics Advisor Partner
All-in-one agent covering ethics, responsible, development, specialist. Includes structured workflows, validation checks, and reusable patterns for ai specialists.