Terragrunt extends Terraform by adding useful wrappers around remote state, dependencies, and configuration generation. If you’re new to Terragrunt, check out the official Terragrunt documentation.
Summary of Terragrunt Blocks
1. terraform Block
Use theterraform block to pass custom flags and settings to the Terraform CLI:
2. remote_state Block
Configure your remote backend once in Terragrunt to avoid repeating it in every module:Always enable state locking (e.g., DynamoDB for S3 backends) to prevent concurrent state modifications.
3. include Block
Share common settings by importing another Terragrunt file:4. locals Block
Define and reuse variables and expressions:5. dependency Block
Declare a single dependency to retrieve outputs from another module:6. dependencies Block
Orchestrate multiple modules by listing them all:terragrunt apply-all, it ensures each module runs in the correct order.
7. generate Block
Automatically generate additional configuration files (HCL or JSON):Next Steps
- Explore Terragrunt Remote State for advanced backend options.
- Learn how to combine
dependencyanddependenciesin a real-world multi-module project. - Check out Terraform CLI Docs for all available commands and flags.