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

Operating System Module

View SourceRelease Notes

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.

Example code

See the operating-system example for working sample code.

Usage

Simply use the module in your Terraform code, replacing <VERSION> with the latest version from the releases page:

module "os" {
source = "git::git@github.com: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 either Linux, Darwin, or Windows

  • 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}"