-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For use in modules that use a lot of conditionals + list variables. This module is a little more convenient than performing the workarounds needed to use conditionals with list values. See: hashicorp/terraform#12453
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
output result { | ||
/* value = "${null_resource.result.triggers.split}" */ | ||
value = "${local.result}" | ||
} | ||
|
||
locals { | ||
then_string = "${join(var.separator, var.then)}" | ||
else_string = "${join(var.separator, var.else)}" | ||
|
||
result_string = "${ | ||
var.equality_condition_left == var.equality_condition_right | ||
? local.then_string | ||
: local.else_string | ||
}" | ||
|
||
result = "${split(var.separator, local.result_string)}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
equality_condition_left = "equal" | ||
equality_condition_right = "noequal" | ||
then = ["then", "list"] | ||
else = ["else", "list", "else"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
variable equality_condition_left { | ||
description = "" | ||
} | ||
|
||
variable equality_condition_right { | ||
description = "" | ||
} | ||
|
||
variable then { | ||
description = "" | ||
type = "list" | ||
} | ||
|
||
variable else { | ||
description = "" | ||
type = "list" | ||
} | ||
|
||
variable separator { | ||
description = "" | ||
default = "^:--:^" | ||
} |