Safe to Delete

Terraform Provider Cache Folder (.terraform/providers)

Quick Answer: The .terraform folder stores downloaded cloud provider binaries (AWS, Azure, GCP). Deleting it is safe and forces a clean terraform init.

Bottom Line: It is 100% safe to delete .terraform folders. Running rm -rf .terraform will NOT delete your infrastructure code (.tf files) or your Terraform state (.tfstate).


What is the .terraform Folder?

Located inside Infrastructure-as-Code projects using HashiCorp Terraform or OpenTofu, the .terraform folder is created when you run terraform init.

Terraform downloads heavy cloud provider binary plugins (like hashicorp/aws, hashicorp/azurerm, or hashicorp/google) into .terraform/providers. Each cloud provider plugin binary is 150 MB to 400 MB.

If you work on dozens of DevOps repositories, duplicate provider binaries in every project directory easily waste 10 GB to 30 GB+.


Can You Delete .terraform?

✅ Yes, it is completely safe to delete.

  • Zero code risk: Your .tf HCL files and remote .tfstate files remain untouched.
  • Auto-downloaded: Running terraform init in the project folder will re-fetch the necessary provider plugins.

How to Safely Clean Up Terraform Cache

Method 1: Delete Local Project .terraform Folders

# macOS / Linux
find . -type d -name ".terraform" -exec rm -rf {} +

# Windows (PowerShell)
Get-ChildItem -Include .terraform -Recurse -Force | Remove-Item -Recurse -Force

Method 2: Enable Global Plugin Cache (Prevents Future Waste)

Add this line to your ~/.terraformrc (or %APPDATA%\terraform.rc on Windows) to share one central plugin binary cache across all project repos:

plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"

Discussion

Loading authentication...

Related in developer

The AI Engineer's Model Disk Cleanup Guide: Hugging Face, Ollama & PyTorch

The ultimate 1,200-word field guide for AI developers and local LLM hobbyists to reclaim 200GB+ from Ollama, Hugging Face, PyTorch, and vLLM model weights.

Safe to Delete

Android Studio System Index Cache (AndroidStudio Cache)

Android Studio caches Gradle project indexes, VFS caches, and compiler artifacts. Invalidate and clear is safe.

Safe to Delete

Ansible Automation Temp & Fact Cache (~/.ansible/tmp)

Ansible stores temporary playbook execution modules and target host fact JSON caches in ~/.ansible/tmp. Clearing Ansible tmp is safe.

Safe to Delete
Back to all files