Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.