Interview Prep/Terraform/Repository Structure, Environments and Module Strategy

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.

All Terraform questions Roadmap: Terraform in production

More on Repository Structure, Environments and Module Strategy