terraform
install_error
ai_generated
true
错误:下载模块失败:无法下载模块:源未找到
Error: Failed to download module: could not download module: source not found
ID: terraform/terraform-init-module-source-error
87%修复率
84%置信度
1证据数
2023-08-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.5.0 | active | — | — | — |
| 1.6.0 | active | — | — | — |
| 1.7.0 | active | — | — | — |
| 1.8.0 | active | — | — | — |
根因分析
配置中指定的模块源 URL 或路径不正确、无法访问或需要身份验证。
English
The module source URL or path specified in the configuration is incorrect, unreachable, or requires authentication.
官方文档
https://developer.hashicorp.com/terraform/language/modules/sources解决方案
-
验证配置中的模块源。例如,如果使用 Git 仓库,请确保 URL 正确:module "vpc" { source = "git::https://github.com/org/terraform-aws-vpc.git?ref=v1.0.0" }。在浏览器中或使用 git clone 测试 URL。 -
如果模块来自 Terraform Registry,请确保源格式为 "namespace/name/provider"。运行 terraform init -from-module=namespace/name/provider 进行测试。
-
对于本地模块,请确保路径相对于根模块且存在。使用绝对路径进行测试:source = "/home/user/modules/my-module"。
无效尝试
常见但无效的做法:
-
Run terraform init -upgrade without checking the source URL.
90% 失败
If the source URL is wrong, upgrading won't fix it; it will just try the same wrong URL again.
-
Set GIT_TERMINAL_PROMPT=1 and hope for an interactive prompt.
70% 失败
This only helps if the source is a private Git repo and you need to enter credentials, but the error says 'source not found', not authentication failure.
-
Delete the .terraform directory and run terraform init again.
95% 失败
This only clears the local cache; it doesn't fix the invalid source reference.