Created
December 5, 2019 06:41
-
-
Save tomdavidson/8a26773cadbd5af9bae87443d93716bf to your computer and use it in GitHub Desktop.
Terraform example loading config from dir of files
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 "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