Skip to content

get_original_terragrunt_dir

unitstack

Usage

get_original_terragrunt_dir() --> string

In a file read with read_terragrunt_config, get_terragrunt_dir returns that file’s directory. get_original_terragrunt_dir returns the directory of the unit that reads it:

shared/naming.hcl
locals {
name = basename(get_original_terragrunt_dir())
}
app/terragrunt.hcl
locals {
naming = read_terragrunt_config("../shared/naming.hcl")
}
inputs = {
name = local.naming.locals.name
}
  • Directoryshared
    • naming.hcl
  • Directoryapp
    • terragrunt.hcl

name is app. When a stack file reads the file, it returns the stack file’s directory.

Examples

In a file that /home/me/infra/app/terragrunt.hcl reads with read_terragrunt_config.

shared/naming.hcl
locals {
unit_dir = get_original_terragrunt_dir() # "/home/me/infra/app"
}