terragrunt
terragrunt documentation
- Version in MegaLinter: 0.76.6
- Visit Official Web Site
- See How to configure terragrunt rules
Configuration in MegaLinter
- Enable terragrunt by adding
TERRAFORM_TERRAGRUNT
in ENABLE_LINTERS variable - Disable terragrunt by adding
TERRAFORM_TERRAGRUNT
in DISABLE_LINTERS variable
- Enable autofixes by adding
TERRAFORM_TERRAGRUNT
in APPLY_FIXES variable
Variable | Description | Default value |
---|---|---|
TERRAFORM_TERRAGRUNT_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
TERRAFORM_TERRAGRUNT_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
TERRAFORM_TERRAGRUNT_FILTER_REGEX_INCLUDE | Custom regex including filter Ex: (src\|lib) |
Include every file |
TERRAFORM_TERRAGRUNT_FILTER_REGEX_EXCLUDE | Custom regex excluding filter Ex: (test\|examples) |
Exclude no file |
TERRAFORM_TERRAGRUNT_CLI_LINT_MODE | Override default CLI lint mode - file : Calls the linter for each file- project : Call the linter from the root of the project |
file |
TERRAFORM_TERRAGRUNT_FILE_EXTENSIONS | Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all filesEx: [".py", ""] |
[".hcl"] |
TERRAFORM_TERRAGRUNT_FILE_NAMES_REGEX | File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files Ex: ["Dockerfile(-.+)?", "Jenkinsfile"] |
Include every file |
TERRAFORM_TERRAGRUNT_PRE_COMMANDS | List of bash commands to run before the linter | None |
TERRAFORM_TERRAGRUNT_POST_COMMANDS | List of bash commands to run after the linter | None |
TERRAFORM_TERRAGRUNT_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling TERRAFORM_TERRAGRUNT and its pre/post commands | None |
TERRAFORM_TERRAGRUNT_CONFIG_FILE | terragrunt configuration file nameUse LINTER_DEFAULT to let the linter find it |
terragrunt.hcl |
TERRAFORM_TERRAGRUNT_RULES_PATH | Path where to find linter configuration file | Workspace folder, then MegaLinter default rules |
TERRAFORM_TERRAGRUNT_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
TERRAFORM_TERRAGRUNT_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
TERRAFORM_TERRAGRUNT_CLI_EXECUTABLE | Override CLI executable | ['terragrunt'] |
MegaLinter Flavors
This linter is available in the following flavors
Flavor | Description | Embedded linters | Info | |
---|---|---|---|---|
![]() |
all | Default MegaLinter Flavor | 125 | |
cupcake | MegaLinter for the most commonly used languages | 86 | ||
security | Optimized for security | 24 | ||
terraform | Optimized for TERRAFORM based projects | 54 |
Behind the scenes
How are identified applicable files
- File extensions:
.hcl
- File name don't ends with:
.tflint.hcl
How the linting is performed
- terragrunt is called one time by identified file (
file
CLI lint mode)
Example calls
terragrunt hclfmt --terragrunt-check --terragrunt-hclfmt-file myfile.hcl
terragrunt hclfmt --terragrunt-check --terragrunt-config terragrunt.hcl --terragrunt-hclfmt-file myfile.hcl
Help content
Usage: terragrunt [global options] <command> [options]
Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
For documentation, see https://terragrunt.gruntwork.io/.
Main commands:
exec Execute an arbitrary command.
graph Execute commands on the full graph of dependent modules for the current module, ensuring correct execution order.
run Run an OpenTofu/Terraform command.
run-all Run a terraform command against a 'stack' by running the specified command in each subfolder.
stack Terragrunt stack commands.
Catalog commands:
catalog Launch the user interface for searching and managing your module catalog.
scaffold Scaffold a new Terragrunt module.
Discovery commands:
find Find relevant Terragrunt configurations.
list List relevant Terragrunt configurations.
Configuration commands:
graph-dependencies Prints the terragrunt dependency graph to stdout.
hclfmt Recursively find hcl files and rewrite them into a canonical format.
hclvalidate Find all hcl files from the config stack and validate them.
info List of commands to display Terragrunt settings.
output-module-groups Output groups of modules ordered by command (apply or destroy) as a list of list in JSON (useful for CI use cases).
render-json Render the final terragrunt config, with all variables, includes, and functions resolved, as json.
terragrunt-info Emits limited terragrunt state on stdout and exits.
validate-inputs Checks if the terragrunt configured inputs align with the terraform defined variables.
OpenTofu shortcuts:
apply Create or update infrastructure.
destroy Destroy previously-created infrastructure.
force-unlock Release a stuck lock on the current workspace.
import Associate existing infrastructure with a OpenTofu/Terraform resource.
init Prepare your working directory for other commands.
output Show output values from your root module.
plan Show changes required by the current configuration.
refresh Update the state to match remote systems.
show Show the current state or a saved plan.
state Advanced state management.
test Execute integration tests for OpenTofu/Terraform modules.
validate Check whether the configuration is valid.
Global Options:
--experiment value Enables specific experiments. For a list of available experiments, see https://terragrunt.gruntwork.io/docs/reference/experiment-mode . [$TG_EXPERIMENT]
--experiment-mode Enables experiment mode for Terragrunt. For more information, see https://terragrunt.gruntwork.io/docs/reference/experiment-mode . (default: false) [$TG_EXPERIMENT_MODE]
--help, -h Show help. (default: false)
--log-custom-format value Set the custom log formatting. [$TG_LOG_CUSTOM_FORMAT]
--log-disable Disable logging. (default: false) [$TG_LOG_DISABLE]
--log-format value Set the log format. [$TG_LOG_FORMAT]
--log-level value Sets the logging level for Terragrunt. Supported levels: stderr, stdout, error, warn, info, debug, trace. (default: info) [$TG_LOG_LEVEL]
--log-show-abs-paths Show absolute paths in logs. (default: false) [$TG_LOG_SHOW_ABS_PATHS]
--no-color Disable color output. (default: false) [$TG_NO_COLOR]
--non-interactive Assume "yes" for all prompts. (default: false) [$TG_NON_INTERACTIVE]
--strict-control value Enables specific strict controls. For a list of available controls, run 'terragrunt info strict'. [$TG_STRICT_CONTROL]
--strict-mode Enables strict mode for Terragrunt. For more information, run 'terragrunt info strict'. (default: false) [$TG_STRICT_MODE]
--version, -v Show terragrunt version. (default: false)
--working-dir value The path to the directory of Terragrunt configurations. Default is current directory. [$TG_WORKING_DIR]
Version: v0.76.6
Author: Gruntwork <www.gruntwork.io>
Installation on mega-linter Docker image
- Dockerfile commands :
# renovate: datasource=docker depName=alpine/terragrunt
ARG TERRAFORM_TERRAGRUNT_VERSION=1.11.2
FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt
COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/