Skip to content

get_terragrunt_source_cli_flag

unitstack

Usage

get_terragrunt_source_cli_flag() --> string

get_terragrunt_source_cli_flag returns the module source set with --source or TG_SOURCE, as given. Without either, it returns an empty string.

Use it for settings that apply only while developing against a local copy of a module, e.g. debug logging:

terragrunt.hcl
locals {
local_dev = get_terragrunt_source_cli_flag() != ""
}
terraform {
extra_arguments "debug" {
commands = ["plan", "apply"]
env_vars = {
TF_LOG = local.local_dev ? "DEBUG" : ""
}
}
}

Examples

During terragrunt run --source ../modules/vpc -- plan.

terragrunt.hcl
locals {
source = get_terragrunt_source_cli_flag() # "../modules/vpc"
}