用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill terraform-terragrunt命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | terraform-terragrunt |
| description | >- Use when this capability is needed. |
Terragrunt is a thin wrapper that keeps Terraform code DRY across many environments by
generating .tf fragments, orchestrating remote state, and coordinating run-all applies.
It is not a replacement for well-factored modules.
include "root" {
path = find_in_parent_folders("root.hcl")
}
terraform {
source = "github.com/myorg/terraform-modules.git//app?ref=v3.2.0"
}
inputs = {
env = "prod"
vpc_id = dependency.network.outputs.vpc_id
stream_arn = dependency.ingest.outputs.stream_arn
}
dependency "network" {
config_path = "../network"
mock_outputs = {
vpc_id = "vpc-mock"
}
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
}
dependency "ingest" {
config_path = "../ingest"
mock_outputs = {
stream_arn = "arn:aws:kinesis:us-east-1:111111111111:stream/mock"
}
mock_outputs_allowed_terraform_commands = ["validate", "plan"]
}
generate "provider" {
path = "provider.tf"
if_exists = "overwrite_terragrunt"
contents = <<EOF
provider "aws" {
region = "us-east-1"
}
EOF
}
Use generate for boilerplate backend.tf / provider.tf files to avoid copy/paste across env
folders - keep generated files .gitignored when policy demands (many teams commit them for
transparency - pick one approach and document).
Terragrunt can configure remote_state once in root.hcl, injecting backend settings per unit -
ensures uniform bucket/key naming (${path_relative_to_include()} patterns).
terragrunt run-all plan --terragrunt-non-interactive
terragrunt run-all apply --terragrunt-non-interactive
Understand parallelism and graph ordering - dependency links define hints; failures mid-run require
manual triage across stacks.
Yes when:
backend/provider snippets.dependency).No when:
Pin Terragrunt versions in CI like Terraform - upgrades can change parsing behavior.
find_in_parent_folders enables hierarchical configuration - great power, great confusion if depth
changes; add comments explaining folder layout in README.
Mock outputs allow validate without live apply of dependencies - misconfigured mocks hide missing
outputs until integration - periodically run full ordered apply in staging.
Generated files might not pass terraform fmt if templates sloppy - lint generation templates.
Terragrunt before_hook / after_hook can run tflint, checkov - keep hooks fast to preserve dev UX.
Wrap terragrunt run-all plan with IAM role assuming per account; matrix by account folder.
Encode account/env in state keys consistently - Terragrunt’s relative path pattern helps until teams move folders - mind refactors.
Terraform-only module authoring → terraform-modules.
bootstrap unit.required_providers mismatches module - test init.Remote backend integration differs - validate whether Terragrunt generation fights Terraform Cloud workspaces - some teams skip Terragrunt in TFC-only flows.
terragrunt hclfmt formats HCL consistently - pre-commit friendly.
Smoke test single unit before run-all in CI to isolate failures faster.
Draw folder tree diagrams in repo root - new hires struggle without visual maps.
Keep complex transforms in Terraform modules, not in inputs = { ... massive ternary ... } -
Terragrunt should orchestrate, not implement algorithms.
Avoid embedding secrets directly - use env vars / SOPS loaders; Terragrunt can read_terragrunt_config
across includes - watch for accidental secret commit in generated files.
run-all may download modules repeatedly - enable download directories caching options (per
Terragrunt version docs) in CI.
Document exit path - some teams graduate to pure Terraform with reusable modules once fleet complexity drops; keep migration notes to avoid lock-in fear.
Terragrunt rewards discipline - without folder conventions and CI guardrails, it amplifies chaos. Use it when repetition pain clearly exceeds wrapper overhead.
Compose configs dynamically - powerful for multi-region loops - beware readability; complex Terragrunt can
be harder to debug than HCL in .tf modules.
find_in_parent_folders behaves differently under Git bash vs PowerShell - standardize dev environment
or document gotchas.
Very deep repos may hit path length limits on Windows - another reason CI uses Linux.
Some teams export Terragrunt dependency graphs into documentation during releases - helps auditors see blast radius ordering.
Workspaces split state within one config; Terragrunt typically splits directories - choose based on desired PR granularity - monolithic workspace PRs scare reviewers.
Even with Terragrunt, backend encryption remains paramount - remote_state config must still set KMS keys.
Generating multiple provider aliases requires careful template testing - one typo duplicates providers block wide.
Use manual gates between plan-all and apply-all stages - full automation without human review is rare
for prod.
If dependency.outputs empty, ensure dependency stack applied - Terragrunt doesn’t auto apply unless
configured - see terraform-troubleshooting for underlying Terraform errors masked by wrapper.
Third-party Terragrunt extensions exist - evaluate support burden before adopting - plain hooks often suffice.
Teams report faster developer onboarding with Terragrunt when folder patterns consistent - measure your
own p50 terragrunt plan times quarterly.
Terragrunt should delete repetition, not add mystery - if new engineers need a two-hour lecture
to run plan, simplify.
Test new Terragrunt versions against oldest supported Terraform in your estate - compat boundaries shift.
Wrap run-all logs with timestamps and unit names - parallel logs interleave confusingly in
naive CI captures.
Use aws ssm get-parameter in before_hook sparingly - failures stall plans; prefer CI to export env.
Point Checkov/Trivy at generated .tf directories when committed - or scan only source modules if
generated files excluded; align policy to avoid blind spots.
After Terragrunt incidents, ask: “Would pure Terraform have been clearer?” Answer honestly quarterly.
Terragrunt is glue - valuable glue, but still glue - don’t let it become the place where unclear architecture hides.
Treat each Terragrunt directory as a unit with contract tests in CI - terragrunt render-json can
snapshot expected inputs for diffs during refactors.
When run-all spans accounts, ensure session naming identifies pipeline job IDs in CloudTrail -
Terragrunt doesn’t add magic; roles must still be least privilege.
If run-all apply fails halfway, rerun only failed units after fixing root cause - document command line
snippets in runbook to avoid accidental full reruns costing time.
Configure TERRAGRUNT_DOWNLOAD paths in CI to reuse module downloads - invalidate when lock files
change - speed matters on large fleets.
Ship shell autocomplete instructions for engineers - small quality-of-life reduces typos in long
run-all invocations.
Back up Terragrunt include trees as zealously as Terraform modules - losing root.hcl hurts as much
as losing backend.tf.
Follow Terragrunt release notes for Terraform compatibility claims - pin pair (TG x.y, TF a.b) in
internal standards doc.
Use terragrunt graph-dependencies (if available in your version) and render to PNG in docs during
major topology changes - picture clarifies ordering arguments in PR reviews.
Atlantis project definitions can call Terragrunt per directory - standardize comment commands (atlantis plan -p network) mapping cleanly to Terragrunt units - confusion here spawns mis-applies.
root.hcl growing unbounded hints missing Terraform module abstraction - refactor repeated inputs
constructs into modules instead of mega includes.
read_terragrunt_config(find_in_parent_folders("encrypted.hcl"))
Keep examples version-controlled without plaintext - pair with age recipients file in repo doc.
Senior engineers should occasionally terragrunt run-all plan locally on laptops mirroring CI,
catching parallelism issues early instead of only in pipelines.
Terragrunt’s payoff is scale: many similar stacks with shared bones - without scale, prefer simpler tools.
Symlink or template terragrunt.hcl per region carefully - accidental symlink loops confuse Git on
Windows; prefer explicit copies with shared root.hcl if symlinks painful.
run-all encourages many stacks - ensure FinOps reviews folder sprawl; inactive stacks still cost money
even if Terragrunt config elegant.
For regulated customers, export rendered Terragrunt JSON inputs per release tag - proves what values were seen during Terraform execution.
Parallelism on laptops can peg CPU - teach TERRAGRUNT_PARALLELISM tuning for humane local dev
experience.
Prefix Terragrunt-managed DynamoDB lock entries (if any) uniquely - some teams share locking infra across mono repo units; misconfiguration causes spooky cross-talk.
VS Code Terragrunt extension maturity fluctuates - fallback to HCL syntax highlighting if specialized features buggy; don’t block adoption on IDE polish.
Promote modules by bumping terraform.source ref sequentially through env folders - git diff of bumps
should be trivially reviewable.
First-time org setup requires S3+Dynamo stack applied before others - Terragrunt dependency cannot
fabricate buckets that don’t exist - human bootstrap still real.
Shorten path_relative_to_include() segments if S3 object key length approaches limits - especially for
deep monorepos.
When debugging, grab terragrunt dag/graph outputs plus underlying terraform plan logs -
wrappers obscure root causes if you only keep Terragrunt stdout.
Terragrunt is not license to skip module semver hygiene - keep modules small; Terragrunt composes, not replaces, module quality.
Used well, Terragrunt reduces copy/paste defects; used poorly, it hides them behind indirection - pick your team’s maturity level honestly.
Source: eclosion-labs/terraform-cursor-plugin — distributed by TomeVault.