How does Terraform scale with thousands of `for_each` instances?
AdvancedProductionHCP Terraform, OpenTofu, Scale and Cost
Answer
Each instance is a graph node with its own refresh call, and the whole plan is held in memory, so CPU, RAM and API calls grow linearly (and some graph steps worse). Symptoms: slow plans and big memory use. Mitigate with splitting by domain, consolidating resources the provider can manage in bulk, and keeping module nesting shallow.
More on HCP Terraform, OpenTofu, Scale and Cost
How do you design workspaces and projects in HCP Terraform?IntermediateWhat execution modes does HCP Terraform offer?BeginnerWhat are the three run workflows in HCP Terraform?BeginnerHow are variable sets and sensitive variables used?BeginnerHow is HCP Terraform priced, and how does it affect design?IntermediateHow do you choose between HCP Terraform, Atlantis, Spacelift and plain GitHub Actions?Advanced