Interview Prep/Terraform/Workflow and Providers

CI runs `terraform init` for 30 stacks and downloads the 400 MB AWS provider every time. How do you speed it up?

IntermediateScenarioWorkflow and Providers
Answer

Situation read → Repeated downloads waste time and bandwidth.

What I'd do →

  1. Set TF_PLUGIN_CACHE_DIR to a persistent directory on the runner.
  2. Cache that directory between jobs (for example actions/cache keyed on the lock file hash).
export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"
mkdir -p "$TF_PLUGIN_CACHE_DIR"
terraform init -input=false

Why → Terraform symlinks cached provider binaries instead of redownloading, so 30 inits share one copy.

Interview tip → The lock file still verifies checksums, so caching doesn't weaken integrity.

All Terraform questions Roadmap: Terraform

More on Workflow and Providers