Skip to content

Instantly share code, notes, and snippets.

@tomdavidson
Created December 5, 2019 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomdavidson/8a26773cadbd5af9bae87443d93716bf to your computer and use it in GitHub Desktop.
Save tomdavidson/8a26773cadbd5af9bae87443d93716bf to your computer and use it in GitHub Desktop.
Terraform example loading config from dir of files
variable "config_files_path" {
default = "../../teams/*.yaml"
description = "The path to team config files"
}
data "local_file" "configs" {
for_each = { for k, file in fileset(dirname(var.config_files_path), basename(var.config_files_path)) :
k => abspath("${dirname(var.config_files_path)}/${file}")
}
filename = each.value
}
locals {
configs = [ for file in data.local_file.configs :
[ for k, group in yamldecode(file.content) :
{k = group}
]
]
config = [ for k, group in local.configs : { for attr, config in group : attr => config } ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment