WindowsmacOSLinux

Where Does Terraform Store Providers and State?

Terraform per-project .terraform directories and the shared plugin cache and CLI config homes.

Last updated

Terraform keeps per-project state (providers, modules) in a .terraform folder next to your .tf files, and shared data (plugin cache, CLI config) in a terraform.d/CLI-config home directory.

The project folder is disposable and regenerable. The shared cache is what saves re-downloads across projects when configured.

Where Terraform stores this, by platform

Windows
%APPDATA%\terraform.d

Shared plugin cache and CLI config home. Set TF_PLUGIN_CACHE_DIR to a plugins subdirectory here to share providers across projects.

macOS
~/.terraform.d

Same role. CLI config file is terraform.rc in home. Per-project .terraform folders sit next to your .tf files.

Linux
~/.terraform.d

Same layout. Export TF_PLUGIN_CACHE_DIR to enable the shared cache; it is off by default.

Frequently asked questions

Can I delete the .terraform folder?

Delete it and run terraform init again. It holds downloaded providers and modules only; your .tf files are untouched. This fixes most provider corruption issues.

Notice an outdated path? Let us know.