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.
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