Local Cache vs. Terraform Cloud Registry: Speed vs. Freshness
0 reputation · 26 Nov 2025, 23:18 UTC
Goal
To guarantee that a Terraform root module uses the most recent code of a referenced module when that module’s source has changed but the version tag has not been bumped.
Constraints & Uncertainty
Terraform stores each module in the .terraform/modules directory to accelerate terraform init. When a module reference specifies a fixed version or tag, Terraform will not fetch a new copy unless the source URL changes or the -upgrade flag is supplied. However, if the module’s content is updated on the registry while the version remains the same, the local cache can become stale. Terraform Cloud’s registry serves the same version content, but client‑side caching still applies, so the stale state may persist unless the cache is explicitly refreshed.
Open Questions
- What built‑in mechanism, if any, does Terraform provide to detect that a cached module is stale after its source has been updated but its version tag is unchanged?
- Does the
-upgradeflag trigger a re‑download of such modules, or does it only check for newer version numbers? - Should CI pipelines rely on
terraform init -reconfigureor manual removal of.terraform/modulesto enforce freshness, and what are the trade‑offs in terms of init time and reliability?