Created
January 3, 2023 08:20
-
-
Save Satak/50a542f5db77c1b51fe0acd0a77b85fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 "environment" { | |
default = "prod" | |
} | |
locals { | |
prefix_folder = "/environments/${var.environment}" | |
folders = { | |
accounts : "accounts" | |
iam_users : "iam_users" | |
} | |
yaml_file_filter = "**/*.yaml" | |
json_file_filter = "**/*.json" | |
config_yaml = { for param, folder in local.folders : | |
(param) => merge(flatten([for file in fileset(path.module, join("/", [local.prefix_folder, folder, local.yaml_file_filter])) : [for doc in split("---", file(file)) : yamldecode(doc)]])...) | |
} | |
config_json = { for param, folder in local.folders : | |
(param) => merge(flatten([for file in fileset(path.module, join("/", [local.prefix_folder, folder, local.json_file_filter])) : jsondecode(file(file))])...) | |
} | |
config = { for param in keys(local.folders) : (param) => merge(local.config_yaml[param], local.config_json[param]) } | |
} | |
output "accounts" { | |
value = local.config.accounts | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment