Skip to content

WiserSolutions/terraform-local-boolean

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircleCI

Terraform module to simplify and expand boolean use

Since Terraform currently doesn't have a boolean variable type, this provides a consistent handling. The list of true values is also expanded.

Designed to simplify the use of booleans (especially where 1 variable is tested many times) and the using count to enable/disable resources.

  • Will handle any capitalization of the input value.
  • Will return 1 for any true value, 0 for anything else.
  • Current true values: true, t, 1, on, enable

All devops-workflow modules will eventually use this.

NOTE: local refers to this using locals and does not create any resources. It just builds new variables.

Terraform registry: https://registry.terraform.io/modules/devops-workflow/boolean/local

Example: If

module "boolean" {
  source  = "devops-workflow/boolean/local"
  value   = "${var.boolean}"
}

var = "${module.boolean.value ? "true setting" : "false setting"}"

Example: count for enabling/disabling a resource

module enabled" {
  source  = "devops-workflow/boolean/local"
  value   = "${var.enabled}"
}

resource "resource_type" "resource_name" {
  count = "${module.enabled.value}"
}