Skip to content

get_repo_root

unitstack

Usage

get_repo_root() --> string

get_repo_root returns the absolute path of the root of the Git repository, e.g. /home/me/infra. It fails when the unit or stack file is not in a Git repository.

Use it to build paths that don’t change with the depth of the unit:

prod/mysql/terragrunt.hcl
inputs = {
config_file = "${get_repo_root()}/config/mysql.yaml"
}

Examples

In a repository checked out at /home/me/infra.

prod/mysql/terragrunt.hcl
locals {
repo_root = get_repo_root() # "/home/me/infra"
}