Interview Prep/Terraform/Workflow and Providers

Someone committed the `.terraform/` directory to the repo. What should be in version control and what should not?

BeginnerScenarioWorkflow and Providers
Answer

Situation read → Classic repo hygiene problem; .terraform/ holds downloaded provider binaries and backend cache.

What I'd do →

  1. Remove it from Git with git rm -r --cached .terraform.
  2. Add a .gitignore.
  3. Keep .terraform.lock.hcl committed.
.terraform/
*.tfstate
*.tfstate.*
crash.log
*.tfplan
override.tf
*.auto.tfvars   # only if they hold secrets

Why → Provider binaries are large and platform-specific, and state or plan files can contain secrets. The lock file is the one generated file that must be shared.

Interview tip → If a state file was ever committed, treat every secret in it as leaked and rotate.

All Terraform questions Roadmap: Terraform

More on Workflow and Providers