nameoptional(string)
The label of the include block to measure from. A unit with more than one include block needs it. In the included file, it has no effect.
path_relative_to_include([name: string]) --> stringA file that many units include can use path_relative_to_include to give each unit its own state key:
remote_state { backend = "s3" generate = { path = "backend.tf" if_exists = "overwrite_terragrunt" } config = { bucket = "my-tofu-state" key = "${path_relative_to_include()}/tofu.tfstate" region = "us-east-1" }}include "root" { path = find_in_parent_folders("root.hcl")}The key is prod/mysql/tofu.tfstate for prod/mysql and stage/mysql/tofu.tfstate for stage/mysql. Without an include block, the function returns ..
A unit with more than one include block passes the label of the one to measure from:
include "root" { path = find_in_parent_folders("root.hcl")}
include "region" { path = find_in_parent_folders("region.hcl")}
inputs = { name = replace(path_relative_to_include("root"), "/", "-")}The label of the include block to measure from. A unit with more than one include block needs it. In the included file, it has no effect.
When prod/mysql/terragrunt.hcl includes this file.
locals { unit_path = path_relative_to_include() # "prod/mysql"}