Linux command
terragrunt 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Initialize modules
terragrunt init
Plan changes
terragrunt plan
Apply changes
terragrunt apply
Destroy infrastructure
terragrunt destroy
Run on all modules
terragrunt run-all apply
Plan all modules
terragrunt run-all plan
Show outputs
terragrunt output
Graph dependencies
terragrunt graph-dependencies
说明
terragrunt is a thin wrapper for Terraform that provides extra tools for keeping configurations DRY and managing multiple modules. DRY configuration avoids repetition across environments. Common settings are defined once and inherited by modules. Remote state configuration is centralized. Backend settings don't need repetition in every module. Dependencies between modules are managed automatically. run-all executes commands across multiple modules in dependency order. Before and after hooks run custom commands around Terraform operations. This enables validation, notifications, and cleanup. Lock file management handles concurrent access. Multiple team members can work safely on shared infrastructure.
参数
- init
- Initialize Terraform.
- plan
- Show execution plan.
- apply
- Apply changes.
- destroy
- Destroy infrastructure.
- output
- Show outputs.
- run-all _CMD_
- Run command on all modules.
- graph-dependencies
- Show dependency graph.
- --terragrunt-config _FILE_
- Config file.
- --terragrunt-working-dir _DIR_
- Working directory.
- --terragrunt-source _SOURCE_
- Module source override.
- --terragrunt-non-interactive
- Non-interactive mode.
- --terragrunt-parallelism _N_
- Parallel operations.
FAQ
What is the terragrunt command used for?
terragrunt is a thin wrapper for Terraform that provides extra tools for keeping configurations DRY and managing multiple modules. DRY configuration avoids repetition across environments. Common settings are defined once and inherited by modules. Remote state configuration is centralized. Backend settings don't need repetition in every module. Dependencies between modules are managed automatically. run-all executes commands across multiple modules in dependency order. Before and after hooks run custom commands around Terraform operations. This enables validation, notifications, and cleanup. Lock file management handles concurrent access. Multiple team members can work safely on shared infrastructure.
How do I run a basic terragrunt example?
Run `terragrunt init` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does init do in terragrunt?
Initialize Terraform.