Run
terragrunt run plan
Plan the unit in this directory
terragrunt run apply
Apply the unit in this directory
terragrunt run init
Initialise the unit
terragrunt run destroy
Destroy the unit
terragrunt run output
Show unit outputs
terragrunt plan
Shortcut for run plan
terragrunt run --all plan
Plan all units below here
terragrunt run --all apply
Apply all units in order
terragrunt run --all destroy
Destroy all, dependents first
terragrunt run --graph plan
Plan this unit and its dependents
Dependents run in graph order; for destroy the order is
reversed.
terragrunt run --all --parallelism <n> plan
Cap concurrent units
terragrunt run --all --no-auto-approve apply
Keep the apply prompt
terragrunt run --all --queue-ignore-dag-order plan
Ignore dependency order
Risky for apply and destroy.
terragrunt run --all --out-dir <dir> plan
Save a plan file per unit
Run apply with the same --out-dir and filters.
terragrunt run --source <path> plan
Override the module source
terragrunt run --tf-path <bin> plan
Pick tofu or terraform binary
terragrunt exec -- <cmd>
Run any command in the unit
Config blocks
Parent terragrunt.hcl: backend and shared code
remote_state { backend = "s3" generate = { path = "backend.tf", if_exists = "overwrite_terragrunt" } config = { bucket = "my-state" key = "${path_relative_to_include()}/tofu.tfstate" region = "eu-central-1" } }
Child unit: include, source, inputs
include "root" { path = find_in_parent_folders("root.hcl") } terraform { source = "git::https://example.com/modules.git//vpc?ref=v1.2.0" } inputs = { cidr = "10.0.0.0/16" }
dependency: read another unit's outputs
dependency "vpc" { config_path = "../vpc" mock_outputs = { vpc_id = "fake" } } inputs = { vpc_id = dependency.vpc.outputs.vpc_id }
dependencies and locals: order only, shared values
dependencies { paths = ["../vpc", "../iam"] } locals { env = basename(get_terragrunt_dir()) }
generate: write a file before each run
generate "provider" { path = "provider.tf" if_exists = "overwrite_terragrunt" contents = "provider \"aws\" { region = \"eu-central-1\" }" }
Hooks and extra arguments
terraform { before_hook "fmt" { commands = ["plan"] execute = ["tofu", "fmt", "-check"] } extra_arguments "vars" { commands = get_terraform_commands_that_need_vars() arguments = ["-var-file=common.tfvars"] } }
Block purpose
Block
Use
include
Inherit a parent file
inputs
Variables passed to the module
dependency
Outputs of another unit
dependencies
Ordering without outputs
remote_state
Backend setup
generate
Write helper files
locals
Named values in the file
feature
Flags set with --feature
include supports one level of nesting only. merge_strategy is
no_merge, shallow or deep; with deep, lists concatenate and maps
merge.
mock_outputs let plan work before the dependency has been
applied. Without them, plan on a fresh stack fails on missing
outputs.