How do you manage hundreds of similar resources from a config file?
AdvancedProductionRepository Structure, Environments and Module Strategy
Answer
Describe them as data (YAML or JSON), decode it and drive for_each.
locals {
teams = yamldecode(file("${path.module}/teams.yaml"))
}
module "team" {
for_each = local.teams
source = "./modules/team"
name = each.key
config = each.value
}
Non-Terraform contributors can submit PRs to the YAML. Validate with variable types in the module so bad data fails early, and watch plan time as the count grows.
More on Repository Structure, Environments and Module Strategy
Monorepo or multi-repo for Terraform?BeginnerHow do you lay out environments in a repo?BeginnerWhen would you adopt Terragrunt?BeginnerDo you use tfvars files per environment or code branches?IntermediateHow do you promote a module change from dev to qa to prod?AdvancedWhat is an internal module registry strategy?Beginner