terragrunt
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "terragrunt":https://skillpi.com/zh/skills/deepskill-494f853d423b7b55a80adb2fe6c3a8b885e6987ecaf2d64e8ec73691d5350b42。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为平台团队提供 Terragrunt 专家支持:Terragrunt 是针对 Terraform 和 OpenTofu 的轻量封装工具,用于保持配置 DRY、管理远程状态并协调多模块部署。帮助利用分层配置、依赖管理与 before/after 钩子,在多个环境和 AWS 账户间管理大规模基础设施。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
Frontmatter
name: terragrunt
description: >-
You are an expert in Terragrunt, the thin wrapper for Terraform and
OpenTofu that provides extra tools for keeping configurations DRY, managing
remote state, and orchestrating multi-module deployments. You help platform
teams manage large-scale infrastructure across multiple environments and AWS
accounts using Terragrunt's hierarchical configuration, dependency
management, and before/after hooks.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Infrastructure & DevOps
tags:
- iac
- terraform
- dry
- infrastructure
- multi-environment
- orchestrationTerragrunt — DRY Terraform/OpenTofu Wrapper
You are an expert in Terragrunt, the thin wrapper for Terraform and OpenTofu that provides extra tools for keeping configurations DRY, managing remote state, and orchestrating multi-module deployments. You help platform teams manage large-scale infrastructure across multiple environments and AWS accounts using Terragrunt's hierarchical configuration, dependency management, and before/after hooks.
Core Capabilities
DRY Configuration
# infrastructure/terragrunt.hcl — Root config (inherited by all children)
remote_state {
backend = "s3"
generate = {
path = "backend.tf"
if_exists = "overwrite"
}
config = {
bucket = "company-terraform-state"
key = "${path_relative_to_include()}/terraform.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "terraform-locks"
}
}
generate "provider" {
path = "provider.tf"
if_exists = "overwrite"
contents = <<EOF
provider "aws" {
region = "${local.region}"
default_tags {
tags = {
Environment = "${local.environment}"
ManagedBy = "terragrunt"
}
}
}
EOF
}
locals {
account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl"))
env_vars = read_terragrunt_config(find_in_parent_folders("env.hcl"))
account_id = local.account_vars.locals.account_id
region = local.region_vars.locals.region
environment = local.env_vars.locals.environment
}
## Directory Structure
infrastructure/
├── terragrunt.hcl # Root config (shared settings)
├── modules/ # Reusable Terraform modules
│ ├── vpc/
│ ├── ecs-service/
│ └── rds/
├── production/
│ ├── account.hcl # account_id = "111111111111"
│ ├── us-east-1/
│ │ ├── region.hcl # region = "us-east-1"
│ │ ├── env.hcl # environment = "production"
│ │ ├── vpc/
│ │ │ └── terragrunt.hcl
│ │ ├── api/
│ │ │ └── terragrunt.hcl
│ │ └── database/
│ │ └── terragrunt.hcl
└── staging/
├── account.hcl # account_id = "222222222222"
└── us-east-1/
├── region.hcl
├── env.hcl # environment = "staging"
├── vpc/
├── api/
└── database/
# infrastructure/production/us-east-1/api/terragrunt.hcl
include "root" {
path = find_in_parent_folders()
}
terraform {
source = "../../../modules/ecs-service"
}
dependency "vpc" {
config_path = "../vpc"
}
dependency "database" {
config_path = "../database"
}
inputs = {
service_name = "api"
vpc_id = dependency.vpc.outputs.vpc_id
subnet_ids = dependency.vpc.outputs.private_subnet_ids
database_url = dependency.database.outputs.connection_string
desired_count = 3 # Production: 3 instances
cpu = 512
memory = 1024
container_image = "company/api:latest"
}
Commands
# Run in a single module
cd infrastructure/production/us-east-1/api
terragrunt plan
terragrunt apply
# Run across ALL modules (respects dependencies)
cd infrastructure/production/us-east-1
terragrunt run-all plan
terragrunt run-all apply
# Run only modules that changed
terragrunt run-all apply --terragrunt-include-dir api --terragrunt-include-dir database
# Graph dependencies
terragrunt graph-dependencies | dot -Tpng > deps.png
Installation
brew install terragrunt
# Or download from https://terragrunt.gruntwork.io/
# Works with both Terraform and OpenTofu
Best Practices
- Hierarchical configs — Use
find_in_parent_folders()to inherit settings; override only what changes per environment - Dependencies — Declare
dependencyblocks; Terragrunt applies in the right order and passes outputs as inputs - Remote state per module — Use
path_relative_to_include()for unique state keys; never share state between modules - run-all for orchestration —
terragrunt run-all applydeploys entire environments respecting dependency order - Separate modules from live config — Reusable modules in
modules/; environment configs reference them viasource - Account/region hierarchy — Structure folders by account → region → environment → service; each level has its
.hcl - Before/after hooks — Use hooks for validation, linting (
tflint), or notifications before/after apply - Works with OpenTofu — Set
TERRAGRUNT_TFPATH=tofuto use OpenTofu instead of Terraform
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- Terragrunt 是基础设施即代码领域的高价值工具,解决多环境、多账户下的 DRY 配置和依赖管理痛点
- 面向平台团队和 DevOps 工程师,具有明确的实用场景和广泛受众
亮点
- 触发描述精准完整,明确限定为 Terragrunt 专家角色
- 覆盖 Terragrunt 核心功能关键词,边界清晰不易误触
待提升项
-
缺少独立 When to Use 章节 原报告严重程度:轻微
文档结构完整但未设置显式的 "When to Use" 章节
改进建议:建议在 Core Capabilities 前增加 "When to Use" 章节,明确说明适用场景(如:多环境部署、需要 DRY 配置、复杂依赖管理等)
亮点
- 文档结构清晰,包含配置示例、目录结构、命令用法和最佳实践
- frontmatter 完整,代码示例丰富且符合官方语法
亮点
- 工具来源明确,参数示例正确,覆盖主要使用场景
- 提及与 OpenTofu 的兼容性,增强实用性
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 160 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- terragrunt.gruntwork.io
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。