Operating System Module
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 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}"
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S PATCHER-TEST MODULE
# ------------------------------------------------------------------------------------------------------
module "patcher_test" {
source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/patcher-test?ref=v0.10.5"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# Sample input for the module
sampleinput = <string>
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S PATCHER-TEST MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-utilities.git//modules/patcher-test?ref=v0.10.5"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# Sample input for the module
sampleinput = <string>
}
Reference
- Inputs
- Outputs
Required
sampleinput
stringSample input for the module