# 错误：下载模块失败：来自 registry.terraform.io/hashicorp/consul/aws 的模块源校验和不匹配

- **ID:** `terraform/module-source-checksum-mismatch`
- **领域:** terraform
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

下载的模块存档的校验和与 Terraform 注册表中预期的校验和不匹配，表明下载损坏或模块被篡改。

## 版本兼容性

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

## 解决方案

1. ```
   清理模块缓存并重新下载：'rm -rf .terraform/modules && terraform init'。
   ```
2. ```
   如果问题持续存在，在源中指定精确模块版本：'source = "hashicorp/consul/aws" version = "0.11.0"' 并运行 'terraform init -upgrade'。
   ```
3. ```
   检查网络连接和代理设置，然后使用不同的镜像：'terraform init -plugin-dir=/path/to/mirror'。
   ```

## 无效尝试

- **** — The corrupted download persists in the .terraform/modules cache. (90% 失败率)
- **** — The lock file will be regenerated with the same mismatch on next init. (80% 失败率)
- **** — May introduce breaking changes or other errors. (60% 失败率)
