Skip to content

constraint_check

unitstack

Usage

constraint_check(version: string, constraint: string) --> bool

constraint_check lets a unit change its configuration with the version of a module it deploys. Here, the module renamed an input in v2.0.0, and a feature flag picks the version:

terragrunt.hcl
feature "module_version" {
default = "1.2.3"
}
locals {
version = feature.module_version.value
v2 = constraint_check(local.version, ">= 2.0.0")
}
terraform {
source = "github.com/acme/modules.git//app?ref=v${local.version}"
}
inputs = local.v2 ? {
new_input_name = "value"
} : {
old_input_name = "value"
}

Setting the flag to 2.0.0, e.g. with --feature module_version=2.0.0, moves the unit to the new module and the new input name in one change.

Parameters

versionstring

The version to check, e.g. 1.2.3. A leading v is allowed.

Examples

terragrunt.hcl
locals {
is_v1 = constraint_check("1.2.3", ">= 1.0, < 2.0") # true
}