Last active
September 28, 2020 21:59
-
-
Save steven-terrana/988f1aa4f5f30b06f140e88a05b3e4cd to your computer and use it in GitHub Desktop.
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
variable "field_A" { | |
type = string | |
default = "default value A" | |
} | |
output "field_A" { | |
value = var.field_A | |
} | |
variable "field_B" { | |
type = string | |
default = "default value B" | |
} | |
output "field_B" { | |
value = var.field_B | |
} |
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
locals { | |
# read values from variables.yaml | |
global = yamldecode(file("variables.yaml")) | |
# map yaml schema to module input variables | |
# default to null if not defined | |
inputs = { | |
field_A = try(local.global.brownfield.field, null) | |
field_B = try(local.global.brownfield.field_B, null) | |
} | |
# filter out values that were not provided by user | |
final = { | |
for field, value in local.inputs: | |
field => value | |
if value != null | |
} | |
} | |
# pass the filtered map of inputs to the module | |
inputs = local.final |
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
terragrunt apply |
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
brownfield: | |
field: "custom field A" | |
field_B: "my custom field B" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment