/iac-automation-skills:terragrunt-configuration-and-dry-run-validationfrom iac-automation-skills
Structures Terragrunt configuration as a DRY layer over Terraform modules across environments, using include/generate/dependency blocks to avoid duplicated backend and provider boilerplate, and validates changes with plan/dry-run workflow before apply.
Ships in iac-automation-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Terragrunt is a thin wrapper around Terraform that solves a problem
Terraform itself doesn't: keeping backend configuration, provider
version constraints, and common variables DRY across dozens of
environment/region/account combinations that would otherwise each need
their own near-duplicate main.tf. It does this by layering
terragrunt.hcl files that include a root configuration and
parameterize a shared Terraform module per environment, then generates
the actual Terraform backend/provider blocks at run time. The
operational risk this introduces is exactly the one Terraform's own
infrastructure-as-code-terraform
skill covers for state and plan review — plus a Terragrunt-specific one:
run-all commands operate across a whole dependency graph of modules at
once, so a run-all apply fanning out unreviewed across every
environment is a materially larger blast radius than a single
terraform apply. This skill covers Terragrunt's DRY layering and the
plan/dry-run discipline needed before that fan-out ever reaches apply.
dev/main.tf,
staging/main.tf, and prod/main.tf are near-identical copies
differing only in backend key and a handful of variables.run-all plan) to validate a shared-module change before it's applied
anywhere.terragrunt.hcl include/generate
block isn't producing the Terraform configuration expected.terragrunt --version output for its bundled
compatibility notes, since Terragrunt's HCL functions and run-all
behavior have changed across major versions (0.5x introduced the
current dependency/dependencies block semantics that replaced older
dependencies { paths = [...] } syntax).run-all command will attempt to assume/use whatever credentials are
configured for each module it touches in the dependency graph.tflint/terraform validate still apply to the underlying .tf
module code; Terragrunt itself has no separate linter beyond
terragrunt hclfmt for HCL formatting.Put shared backend/provider config in a root terragrunt.hcl,
generated once and included everywhere rather than repeated:
# live/terragrunt.hcl (root)
remote_state {
backend = "s3"
generate = { path = "backend.tf", if_exists = "overwrite_terragrunt" }
config = {
bucket = "example-tfstate-<AWS_ACCOUNT_ID>"
key = "${path_relative_to_include()}/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks"
encrypt = true
}
}
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<-EOF
provider "aws" {
region = "${local.region}"
}
EOF
}
locals {
region = "us-east-1"
}
path_relative_to_include() derives a unique state key per environment
automatically, so no environment's terragrunt.hcl needs to restate
the backend block at all.
Each environment/module directory includes the root and points at
a versioned module source, keeping the diff between environments
down to just the inputs that actually differ:
# live/prod/vpc/terragrunt.hcl
include "root" {
path = find_in_parent_folders()
}
terraform {
source = "git::https://github.com/example-org/tf-modules.git//vpc?ref=v3.2.0"
}
inputs = {
cidr_block = "10.20.0.0/16"
environment = "prod"
enable_nat_gateway = true
}
# live/dev/vpc/terragrunt.hcl
include "root" {
path = find_in_parent_folders()
}
terraform {
source = "git::https://github.com/example-org/tf-modules.git//vpc?ref=v3.2.0"
}
inputs = {
cidr_block = "10.10.0.0/16"
environment = "dev"
enable_nat_gateway = false
}
Pinning ?ref=v3.2.0 on the module source means a module change
doesn't silently propagate to every environment on the next
terragrunt plan — each environment upgrades its pinned ref
deliberately.
Wire cross-module data with dependency blocks instead of hand-
written remote state data sources, so Terragrunt resolves another
module's outputs automatically and fails loudly if that module hasn't
been applied yet:
# live/prod/app-tier/terragrunt.hcl
include "root" {
path = find_in_parent_folders()
}
dependency "vpc" {
config_path = "../vpc"
mock_outputs = {
vpc_id = "vpc-mock00000000000"
subnet_ids = ["subnet-mock1", "subnet-mock2"]
}
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
}
terraform {
source = "git::https://github.com/example-org/tf-modules.git//app-tier?ref=v1.8.0"
}
inputs = {
vpc_id = dependency.vpc.outputs.vpc_id
subnet_ids = dependency.vpc.outputs.subnet_ids
}
mock_outputs let plan/validate succeed even before the dependency
has real outputs (useful in CI on a fresh environment), while
restricting mock_outputs_allowed_terraform_commands ensures a real
apply still fails fast if the actual dependency hasn't been applied.
Dry-run a single module before touching anything shared:
cd live/prod/vpc
terragrunt plan
Read the plan exactly as you would a plain terraform plan — this is
the same review discipline as
infrastructure-as-code-terraform,
just invoked through the Terragrunt wrapper.
Validate a multi-module change with run-all plan before any
run-all apply. This walks the dependency graph and plans every
affected module in the correct order:
cd live/prod
terragrunt run-all plan
Review the aggregated output per module carefully — run-all prints
each module's plan in sequence, and it is easy to skim past one
module's unexpected destroy buried between two clean ones.
Never run run-all apply unreviewed across a whole environment.
Warning:
terragrunt run-all apply(and especiallyrun-all destroy) fans out across every module in the current directory's dependency graph. Runrun-all planfirst, review it in full, and prefer scoping to the smallest actual change:
# Prefer touching one module at a time when only one changed:
cd live/prod/app-tier && terragrunt plan && terragrunt apply
# Only use run-all when a genuinely cross-cutting change (e.g. a
# shared module version bump) requires it, and always plan first:
cd live/prod && terragrunt run-all plan
# ...review every module's plan output...
cd live/prod && terragrunt run-all apply --terragrunt-non-interactive=false
Avoid --terragrunt-non-interactive (which skips Terragrunt's own
per-module confirmation prompts) for any run-all apply against a
shared or production environment.
Use terragrunt validate-inputs and hclfmt in CI to catch a
terragrunt.hcl referencing an input the underlying module doesn't
declare (or vice versa) before it reaches a human reviewer:
terragrunt hclfmt --terragrunt-check
terragrunt validate-inputs
terragrunt.hcl to include the root
config rather than partially duplicating it — if two environments'
root includes diverge, DRY has already been lost.ref= tags explicitly (never a floating branch like ref=main)
so terragrunt plan in prod can't unexpectedly pick up an
in-flight change to the module still being tested in dev.run-all plan (never run-all apply directly) in CI on every PR
touching shared module code or root config, and require a human to
read the per-environment plan diffs before merge — mirroring the CI
plan-review gate from
infrastructure-as-code-terraform.run-all commands to the narrowest directory that actually needs
it (cd live/staging/app-tier rather than cd live from the repo
root) to keep blast radius intentional.mock_outputs as a CI/dry-run convenience only — never allow
apply to proceed against mocked dependency outputs
(mock_outputs_allowed_terraform_commands should exclude apply).Symptom: terragrunt plan in one environment unexpectedly reflects
a change someone else is still testing in a different environment.
Fix: The module source ref= is likely unpinned (pointing at a
branch, not a tag/commit) — pin every environment's module source to an
explicit version and bump it deliberately per environment as changes
are promoted.
Symptom: run-all plan fails with a dependency error before it
even reaches the module being changed.
Fix: A dependency block's target module hasn't been applied yet
in this environment (no state to read outputs from) and
mock_outputs/mock_outputs_allowed_terraform_commands either isn't
set or doesn't cover the command being run. Add mock outputs scoped to
plan/validate only, and apply the dependency module for real before
the dependent module's first real apply.
Symptom: A generated backend.tf/provider.tf file conflicts with
a hand-written one already in the module, causing a "duplicate backend
configuration" error.
Fix: Don't hand-write backend/provider blocks inside modules meant
to be consumed via Terragrunt's generate block — the module should be
backend/provider-agnostic, and only the live repo's root
terragrunt.hcl generates those blocks. Set if_exists = "overwrite_terragrunt" deliberately if a transitional period requires
both.
Symptom: Someone runs terragrunt run-all apply from the repo root
intending to apply one small change, and it fans out an apply across
every environment's module in the tree, including production.
Fix: This is a destructive/dangerous action if the working
directory wasn't scoped correctly — always cd into the narrowest
directory that contains only the modules actually intended to change,
run run-all plan first and read every module's output, and never
invoke run-all apply from a directory whose subtree spans more than
one environment unless that cross-environment change is genuinely
intended and reviewed.
Symptom: CI's run-all plan output is thousands of lines and a
reviewer can't tell which module actually has a meaningful diff.
Fix: Use terragrunt run-all plan --terragrunt-non-interactive 2>&1 | tee plan.log and post a summarized diff per module (grep for
Plan: N to add, N to change, N to destroy per module block) as the
PR comment, reserving full raw output as a linked artifact rather than
the inline comment body.
Scenario: A platform team maintains a vpc module and an
app-tier module across dev, staging, and prod. They bump the
app-tier module from v1.7.0 to v1.8.0 (adds a new required input)
and need to validate the change across all three environments before
applying anywhere.
Root config (live/terragrunt.hcl), unchanged from the standard layout
in step 1.
live/staging/app-tier/terragrunt.hcl before the change:
include "root" {
path = find_in_parent_folders()
}
dependency "vpc" {
config_path = "../vpc"
}
terraform {
source = "git::https://github.com/example-org/tf-modules.git//app-tier?ref=v1.7.0"
}
inputs = {
vpc_id = dependency.vpc.outputs.vpc_id
subnet_ids = dependency.vpc.outputs.subnet_ids
instance_type = "t3.medium"
}
Change: bump the ref and add the new required input introduced by
v1.8.0:
terraform {
source = "git::https://github.com/example-org/tf-modules.git//app-tier?ref=v1.8.0"
}
inputs = {
vpc_id = dependency.vpc.outputs.vpc_id
subnet_ids = dependency.vpc.outputs.subnet_ids
instance_type = "t3.medium"
enable_autoscaling = true # new required input in v1.8.0
}
Dry-run validation, staging first:
cd live/staging/app-tier
terragrunt plan
# Plan: 1 to add, 1 to change, 0 to destroy
# (new autoscaling group resource, launch template updated in place)
Repeated identically in dev, then reviewed in a PR, then applied to
staging alone (terragrunt apply) and observed for a day before the
same two-line change is copied to prod/app-tier/terragrunt.hcl and its
own terragrunt plan is reviewed before that environment's apply. At
no point is run-all apply used, since only one module per environment
actually changed — run-all is reserved for the (separate) case of a
root-config change that legitimately affects every module at once.
terragrunt apply actually produced working infrastructure, beyond a clean plan/apply exit code.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin iac-automation-skills14 skills in this plugin
/ansible-playbook-and-role-designDesigns and safely runs Ansible playbooks, roles, and inventories for configuration management, including idempotent task design, Ansible Vault for secrets, and choosing config-management (Ansible) versus provisioning (Terraform/CloudFormation) for a given change. Use when the user asks to "write an Ansible playbook/role for X," "structure an Ansible inventory across environments," "make this task idempotent," "encrypt secrets with Ansible Vault," "dry-run a playbook before production," or "should this be Ansible or Terraform."
/aws-cloudformation-templatesAuthors and safely operates AWS CloudFormation templates (YAML/JSON), including stacks, change sets, nested and cross-stack references, StackSets for multi-account/multi-region deployment, and drift detection. Use when the user asks to "write a CloudFormation template for X," "structure nested CloudFormation stacks," "deploy the same stack across AWS accounts/regions," "review a CloudFormation change set before applying," "detect/reconcile drift on a stack," or "migrate/compare CloudFormation with Terraform" for an AWS-native IaC choice.
/chef-puppet-saltstack-legacy-config-managementProvides a comparative overview of Chef, Puppet, and SaltStack for teams maintaining existing legacy configuration-management estates alongside or instead of Ansible — agent-based pull architecture, DSL/resource models (Chef recipes/cookbooks, Puppet manifests/catalogs, Salt states/pillars), and a candid assessment of where each still earns its keep in a modern enterprise versus where it's inertia. Use when the user asks to "maintain this existing Chef/Puppet/Salt estate," "write a Chef recipe/Puppet manifest/Salt state," "should we migrate off Puppet to Ansible," "why is our Puppet run applying a change we didn't expect," or "compare Chef vs. Puppet vs. SaltStack."
/feature-flag-configuration-launchdarkly-and-unleashDesigns and operates feature flag configuration with LaunchDarkly or Unleash, covering flag lifecycle (create, target, roll out, retire), kill-switch patterns for fast incident mitigation without a redeploy, targeting/segmentation rules, and cleaning up stale flag debt before it accumulates into unreadable conditional logic. Use when the user asks to "add a feature flag for X," "set up a kill switch for this feature," "configure LaunchDarkly/Unleash targeting rules," "roll out a flag gradually by percentage," "clean up old feature flags," or "should we use LaunchDarkly or self-host Unleash."
/gremlin-chaos-engineering-configurationConfigures Gremlin-specific chaos engineering attacks — installing the Gremlin agent/sidecar, defining resource, state, and network attacks via the Gremlin API/CLI or Terraform provider, scoping blast radius with targets and halt conditions, and running Gremlin Scenarios for multi-step failure sequences. Use when the user asks to "configure a Gremlin attack," "set up the Gremlin agent in Kubernetes/EC2," "write a Gremlin Scenario," "scope a Gremlin blast radius/halt condition," or "use Gremlin to test our failover." For the general chaos-engineering principles (steady-state hypothesis, game days, tool-agnostic blast radius scoping) this configures against, use the SRE chaos-engineering-and-resilience-testing skill instead.
/infrastructure-post-deployment-validation-and-smoke-testingVerifies that a Terraform apply, CloudFormation deploy, or Ansible playbook run actually produced working infrastructure — resource existence and configuration checks, connectivity/health smoke tests, and automated post-apply assertions — rather than treating a clean "apply succeeded" exit code as proof the system works. Use when the user asks to "verify this deployment actually worked," "write a smoke test after terraform apply/cloudformation deploy," "check the resource is actually reachable/configured correctly post-deploy," "add post-deployment validation to the pipeline," or "our apply succeeded but the service is down."
Other plugins' skills for the same job