pathstring
The path to convert.
to_slash(path: string) --> stringOn Windows, the Terragrunt functions that return a path separate its parts with backslashes. Wrap a path in to_slash where a value built from it must be the same on every operating system, e.g. a state key:
remote_state { backend = "s3" generate = { path = "backend.tf" if_exists = "overwrite_terragrunt" } config = { bucket = "my-tofu-state" key = "${to_slash(path_relative_to_include())}/tofu.tfstate" region = "us-east-1" }}For prod/mysql/terragrunt.hcl on Windows, path_relative_to_include() returns prod\mysql, and the key is prod/mysql/tofu.tfstate.
On Linux and macOS, to_slash returns path unchanged, backslashes included. To go the other way, use from_slash.
The path to convert.
inputs = { unit_dir = to_slash(get_terragrunt_dir()) # "C:/work/live/app" on Windows}