This is a module that can be used to figure out what operating system is being used to run Terraform. This may be used to modify Terraform's behavior depending on the OS, such as modifying the way you format file paths on Linux vs Windows (see also the join-path module).
This module uses Python under the hood so, the Python must be installed on the OS.
See the operating-system example for working sample code.
Simply use the module in your Terraform code, replacing <VERSION>
with the latest version from the releases
page:
module "os" {
source = "git::[email protected]:gruntwork-io/terraform-aws-utilities.git//modules/operating-system?ref=<VERSION>"
}
-
You can now get the name of the operating system from the
name
output, which will be set to eitherLinux
,Darwin
, orWindows
-
You can also get the path separator for the current OS—backslash for Windows, forward slash everywhere else—from the
path_separator
output.
operating_system_name = "${module.os.name}"
path_separator = "${module.os.path_separator}"