The Module not installed error occurs when Terraform cannot find or load a referenced module. This happens when you reference a module in your configuration but haven't run terraform init or the module source is invalid.
This error indicates that Terraform has encountered a reference to a module in your configuration (either local or remote) but the module files are not present in the .terraform directory. Terraform manages module dependencies in the .terraform folder after running terraform init. The error prevents Terraform from understanding the full configuration structure needed to plan or apply changes.
Execute the terraform init command in your working directory. This command initializes Terraform, installs all required providers, and downloads all referenced modules:
terraform initThis is the most common solution. Terraform will scan your configuration files, find all module references, and download them into the .terraform/modules directory.
Check your .tf files for module declarations. Ensure the source path is correct:
module "example" {
source = "./modules/my-module" # Local module
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws" # Registry module
version = "~> 5.0"
}
module "network" {
source = "git::https://github.com/org/repo.git//modules/network" # Git module
}Common issues:
- Typos in the source path
- Incorrect case (especially on case-sensitive filesystems)
- Missing the double slash (//) for subdirectories in Git modules
- Outdated or incorrect Git repository URLs
If the error persists after checking the module sources, the cache may be corrupted. Remove it and reinitialize:
rm -rf .terraform
rm .terraform.lock.hcl
terraform initThis removes the cached modules and lock file, forcing Terraform to re-download everything fresh.
If you recently changed module version constraints, use the -upgrade flag to force Terraform to check for newer versions:
terraform init -upgradeThis is useful when:
- You updated version constraints in your module block
- You want to fetch the latest compatible version
- Previous module versions are cached but no longer valid
For remote modules (from Git or the Terraform Registry), verify:
1. Internet connectivity: Ensure your system can reach the module source:
ping github.com2. Git authentication (for private repositories): Configure Git credentials:
git config --global credential.helper store
git clone <your-private-repo>3. Terraform Registry access: The public registry at registry.terraform.io should be accessible. If you use a private registry, configure it in your .terraformrc:
credentials "app.terraform.io" {
token = "YOUR_API_TOKEN"
}4. Firewall/proxy rules: Ensure no firewall blocks access to module sources.
Run terraform validate to catch syntax errors in your configuration:
terraform validateThis checks for:
- Invalid module block syntax
- Undefined variable references
- Missing required arguments
- Circular dependencies
Fix any reported errors before running terraform init again.
Module installation in Terraform follows a specific process: 1) Terraform scans all .tf files for module blocks, 2) it identifies all unique module sources, 3) it checks the lock file (.terraform.lock.hcl) for cached versions, 4) it downloads missing modules to .terraform/modules/, and 5) it creates a manifest file. The lock file ensures reproducible module installations across team members. For remote modules from Git or the Registry, Terraform caches them locally to avoid repeated downloads. The error occurs if any step fails or if the .terraform directory is incomplete. When using local modules, ensure the relative or absolute path exists and contains at least one .tf file. For Registry modules, the format must be namespace/name/provider or organization/module/provider for private registries. Module initialization is independent of provider installation—both happen during terraform init but use separate cache systems.
Error: Error installing helm release: cannot re-use a name that is still in use
How to fix "release name in use" error in Terraform with Helm
Error: Error creating GKE Cluster: BadRequest
BadRequest error creating GKE cluster in Terraform
Error: External program failed to produce valid JSON
External program failed to produce valid JSON
Error: Unsupported argument in child module call
How to fix "Unsupported argument in child module call" in Terraform
Error: network is unreachable
How to fix "network is unreachable" in Terraform