Skip to content

Instantly share code, notes, and snippets.

@steven-terrana
Last active September 28, 2020 21:59
Show Gist options
  • Save steven-terrana/988f1aa4f5f30b06f140e88a05b3e4cd to your computer and use it in GitHub Desktop.
Save steven-terrana/988f1aa4f5f30b06f140e88a05b3e4cd to your computer and use it in GitHub Desktop.
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
}
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
terragrunt apply
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