Skip to content

terragrunt

GitHub stars autofix GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

terragrunt documentation

terragrunt - GitHub

Configuration in MegaLinter

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 files
Ex: [".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 127 Docker Image Size (tag) Docker Pulls
cupcake MegaLinter for the most commonly used languages 88 Docker Image Size (tag) Docker Pulls
security Optimized for security 24 Docker Image Size (tag) Docker Pulls
terraform Optimized for TERRAFORM based projects 54 Docker Image Size (tag) Docker Pulls

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:
   backend        Interact with OpenTofu/Terraform backend infrastructure.
   exec           Execute an arbitrary command.
   run            Run an OpenTofu/Terraform command.
   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, fd       Find relevant Terragrunt configurations.
   list, ls       List relevant Terragrunt configurations.

Configuration commands:
   dag            Interact with the Directed Acyclic Graph (DAG).
   hcl            Interact with HCL files.
   info           List of commands to display Terragrunt settings.
   render         Render the final terragrunt config, with all variables, includes, and functions resolved, in the specified format.

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]
   --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]
   --working-dir value        The path to the directory of Terragrunt configurations. Default is current directory. [$TG_WORKING_DIR]
   --help, -h                 Show help. (default: false)
   --version, -v              Show terragrunt version. (default: false)

Version: v0.78.0

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.4
FROM alpine/terragrunt:${TERRAFORM_TERRAGRUNT_VERSION} AS terragrunt
COPY --link --from=terragrunt /usr/local/bin/terragrunt /usr/bin/