Names the unit. Names are unique within a stack file. terragrunt stack output lists the unit’s outputs under its name, and unit.<name>.path refers to its generated directory in autoinclude blocks and in values.
unit
Usage
The unit block defines a unit in a terragrunt.stack.hcl file. terragrunt stack generate fetches the unit’s configuration from source into path, under the stack’s .terragrunt-stack directory, and writes values to a terragrunt.values.hcl file next to it:
unit "vpc" { source = "../catalog/units/vpc" path = "vpc" values = { cidr = "10.0.0.0/16" }}- terragrunt.stack.hcl
Directory.terragrunt-stack
Directoryvpc
- terragrunt.hcl
- terragrunt.values.hcl
The generated terragrunt.hcl file comes from source, and reads values from terragrunt.values.hcl:
inputs = { cidr = values.cidr}Where the unit is generated
path is relative to the stack’s .terragrunt-stack directory. Set no_dot_terragrunt_stack to make it relative to the stack file’s directory instead:
By default:
unit "rds" { source = "../catalog/units/rds" path = "rds"}- terragrunt.stack.hcl
Directory.terragrunt-stack
Directoryrds
- terragrunt.hcl
With no_dot_terragrunt_stack:
unit "rds" { source = "../catalog/units/rds" path = "rds"
no_dot_terragrunt_stack = true}- terragrunt.stack.hcl
Directoryrds
- terragrunt.hcl
Related blocks
To generate more than one unit from a block, add an expansion block. To add dependencies or other configuration to the generated unit, add an autoinclude block.
To choose between a unit block and a stack block, see Unit and stack blocks.
Labels
Attributes
Where to fetch the unit’s configuration from, in the same syntax as the source attribute of the terraform block. The --source-map flag can replace it.
unit "vpc" { source = "git::https://github.com/acme/units.git//vpc?ref=v1.0.0" path = "vpc"}The directory to generate the unit in, relative to the stack’s .terragrunt-stack directory. Each unit in a stack file needs its own path. Terragrunt rejects an absolute path and a path that leaves the stack directory.
unit "vpc" { source = "../catalog/units/vpc" path = "networking/vpc"}Values to write to a terragrunt.values.hcl file next to the unit’s terragrunt.hcl file. The unit reads each one as values.<name>. A terragrunt.values.hcl file in the unit’s source supplies the values when the block sets none, and values replaces it otherwise.
unit "vpc" { source = "../catalog/units/vpc" path = "vpc"
values = { vpc_name = "main" cidr = "10.0.0.0/16" }}When false, Terragrunt skips the unit during stack generation and leaves it out of terragrunt stack output. Changing it leaves the unit’s address and path unchanged. See enabled vs expansion.
locals { deploy_canary = false}
unit "canary" { source = "../catalog/units/app" path = "canary"
enabled = local.deploy_canary}Resolves path against the stack file’s directory, so the unit is generated outside .terragrunt-stack. Use it to move existing units into a stack file without moving their directories or their state. See Where the unit is generated.
unit "rds" { source = "../catalog/units/rds" path = "rds"
no_dot_terragrunt_stack = true}Skips the check that the generated directory has a terragrunt.hcl file at its root. Terragrunt also skips it for a unit with no_dot_terragrunt_stack set. The --no-stack-validate flag skips it for every unit and stack.
unit "legacy" { source = "../catalog/units/legacy" path = "legacy"
no_validation = true}Lets a catalog’s stack file give source as a path relative to the catalog. Terragrunt rewrites it to a reference into its content-addressable store. See CAS integration.
unit "service" { source = "../..//units/service" path = "service"
update_source_with_cas = true}Makes the files Terragrunt copies from its content-addressable store into the unit’s directory writable. Terragrunt writes them read-only by default, so an edit can’t reach the shared store.
unit "service" { source = "git::https://github.com/acme/units.git//service?ref=v1.0.0" path = "service"
mutable = true}