Skip to content

exclude

unit

Usage

With a feature flag in if, a unit can stay out of run --all until a run opts in:

live/canary/terragrunt.hcl
feature "canary" {
default = false
}
exclude {
if = !feature.canary.value
actions = ["all_except_output"]
}
Terminal window
# Applies every unit in live except canary.
terragrunt run --all -- apply
# Applies canary too.
terragrunt run --all --feature canary=true -- apply

See Excludes for more patterns, e.g. excluding units per environment from a shared root.hcl.

Attributes

ifbool

Whether to exclude the unit. It’s an expression, e.g. a feature flag, but it can’t read dependency outputs, because Terragrunt evaluates it while building the run queue, before any dependency has run.

terragrunt.hcl
feature "skip_unit" {
default = false
}
exclude {
if = feature.skip_unit.value
actions = ["all"]
}
actionslist(string)

The OpenTofu/Terraform commands to exclude the unit from, e.g. plan or apply. all matches every command, and all_except_output matches every command except output, so other units can still read this unit’s outputs through dependency blocks.

terragrunt.hcl
exclude {
if = true
actions = ["all_except_output"]
}
no_runoptional(bool, false)

Also stops a single-unit command, e.g. terragrunt run -- plan, when if is true and actions matches the command. Without it, exclude only affects a run queue, e.g. run --all.

terragrunt.hcl
exclude {
if = true
no_run = true
actions = ["plan"]
}
exclude_dependenciesoptional(bool, false)

Also leaves out the units this unit depends on.

terragrunt.hcl
feature "is_dev_environment" {
default = false
}
exclude {
if = feature.is_dev_environment.value
actions = ["all"]
exclude_dependencies = true
}