Created
July 11, 2021 17:28
-
-
Save shubhamoli/03796f096521cbdbdafaf4802ea715d4 to your computer and use it in GitHub Desktop.
terraform optional keys in maps
This file contains hidden or 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
locals { | |
required_value = { | |
RequiredValue = "${var.required}" | |
} | |
optional_value = { | |
exists = { | |
OptionalValue = "${var.optional}" | |
} | |
not_exists = {} | |
} | |
final_value = "${merge( | |
local.required_value, | |
local.optional_value[var.optional != "" ? "exists" : "not_exists"] | |
)}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment