# 错误：模块未找到：模块 "vpc" 源 "terraform-aws-modules/vpc/aws" 在注册表中未找到

- **ID:** `terraform/module-source-not-found`
- **领域:** terraform
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

指定的模块源在Terraform注册表中不存在，或版本约束与任何已发布版本不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Terraform v1.5.0 | active | — | — |
| Terraform v1.6.0 | active | — | — |
| Terraform v1.7.0 | active | — | — |

## 解决方案

1. ```
   Verify the module name and namespace in the Terraform registry: `terraform-aws-modules/vpc/aws` is correct; check for typos. Then run 'terraform init'.
   ```
2. ```
   If the module is private, add a module source with a Git URL: `source = "git::https://github.com/org/terraform-aws-vpc.git?ref=v3.0.0"` and run 'terraform init'
   ```

## 无效尝试

- **Run 'terraform init' without any flags** — Init can only install modules if the source is valid; it won't fix a non-existent source. (95% 失败率)
- **Use a local file path instead of the registry source** — The local path must contain the module; a random path won't work. (80% 失败率)
- **Add a version constraint like 'version = "latest"'** — The module doesn't exist at all; no version constraint can fix that. (90% 失败率)
