Terraform "Failed to read module manifest" in CI
Terraform reads .terraform/modules/modules.json to know where each installed module lives. When that manifest is missing, truncated, or invalid JSON, init or plan fails because the module layout cannot be resolved.
What this error means
terraform init or plan stops with "Error: Failed to read module manifest" and a JSON or file-read error for .terraform/modules/modules.json.
Error: Failed to read module manifest
Module installer was unable to read the manifest file
".terraform/modules/modules.json": unexpected end of JSON input.Common causes
A partial or corrupt cache of .terraform
A cache restore that ran mid-write, or an interrupted previous init, left modules.json truncated or invalid.
A stale manifest carried across incompatible changes
An old manifest from a different config layout no longer parses cleanly against the current modules.
How to fix it
Delete the module cache and re-init
- Remove the
.terraform/modulesdirectory (or all of.terraform). - Run
terraform initto rebuild the manifest from scratch. - Re-run plan against the clean install.
rm -rf .terraform/modules
terraform init -input=falseDo not cache a half-written .terraform
Cache .terraform only after a successful init, and key it on the config so partial state is not restored.
How to prevent it
- Rebuild
.terraform/moduleswith a fresh init when the manifest is corrupt. - Avoid caching
.terraformfrom failed or interrupted jobs. - Key module caches on config and lock files.