Interview Prep/Terraform/HCP Terraform, OpenTofu, Scale and Cost

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.

All Terraform questions

More on HCP Terraform, OpenTofu, Scale and Cost