Skip to main content
Terraform Utility Modules 0.10.0Last updated in version 0.9.6

Join Path Module

View SourceRelease Notes

This is a module that can be used to join a list of given path parts (that is, file and folder names) into a single path with the appropriate path separator (backslash or forward slash) for the current operating system. This is useful for ensuring the paths you build will work properly on Windows, Linux, and OS X.

This module uses Python under the hood so, the Python must be installed on the OS.

Example code

See the join-path example for working sample code.

Usage

Simply use the module in your Terraform code, replacing <VERSION> with the latest version from the releases page, and specifying the path parts using the path_parts input:

module "path" {
source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/join-path?ref=<VERSION>"

path_parts = ["foo", "bar", "baz.txt"]
}

You can now get the joined path using the path output:

# Will be set to "foo/bar/baz.txt" on Linux and OS X, "foo\bar\baz.txt" on Windows
joined_path = "${module.path.path}"

Sample Usage

main.tf

# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S JOIN-PATH MODULE
# ------------------------------------------------------------------------------------------------------

module "join_path" {

source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/join-path?ref=v0.10.0"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------

# A list of folder and file names to combine into a path, using the proper
# path separator for the current OS.
path_parts = <list(string)>

}


Reference

Required

path_partslist(string)required

A list of folder and file names to combine into a path, using the proper path separator for the current OS.

Example
   path_parts = ["foo", "bar", "baz.txt"] => outputs "foo/bar/baz.txt" on Linux