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

A plan takes 40 minutes. How do you speed it up?

AdvancedProductionHCP Terraform, OpenTofu, Scale and Cost
Answer

First find out why: TF_LOG=DEBUG timestamps or trace the provider calls. Typical fixes: split the state into smaller stacks (biggest win), disable refresh for data sources that are slow or replace them with variables, reduce data lookups in loops, raise -parallelism if the API allows, stop using for_each over thousands of tiny resources where a single higher-level resource supports lists, cache providers and run on a runner close to the API. -refresh=false and -target are band-aids, not a strategy.

All Terraform questions

More on HCP Terraform, OpenTofu, Scale and Cost