LinuxCommandLibrary

terragrunt

Terraform wrapper for DRY configurations

TLDR

Initialize modules

$ terragrunt init
copy
Plan changes
$ terragrunt plan
copy
Apply changes
$ terragrunt apply
copy
Destroy infrastructure
$ terragrunt destroy
copy
Run on all modules
$ terragrunt run-all apply
copy
Plan all modules
$ terragrunt run-all plan
copy
Show outputs
$ terragrunt output
copy
Graph dependencies
$ terragrunt graph-dependencies
copy

SYNOPSIS

terragrunt [init] [plan] [apply] [destroy] [run-all] [options]

DESCRIPTION

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.

PARAMETERS

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.

CONFIGURATION

terragrunt.hcl

Module-level configuration file defining Terraform source, inputs, dependencies, and backend settings
TERRAGRUNT_CONFIG
Environment variable to override the default configuration file path
TERRAGRUNT_DOWNLOAD
Environment variable to set the directory where Terragrunt downloads Terraform source code

CAVEATS

Adds complexity over plain Terraform. Learning curve for configuration syntax. Some Terraform features need workarounds.

HISTORY

Terragrunt was created by Gruntwork around 2016 to address pain points in managing Terraform at scale. It's widely used for multi-environment, multi-account infrastructure management.

SEE ALSO

terraform(1), pulumi(1), aws(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community