当从本地源调用一个模块时,一切正常,但是我决定重构Terraform代码,为模块使用git存储库。
我在我们的BitBucket帐户中创建了一个名为terraform-modules的新存储库,并重构了模块的源属性,使其具有以下结构:
source = "git::ssh://git@bitbucket.org:carepaydev/terraform-modules.git//modules/iam/iam_roles/assumable_role"当调用terraform init时,我得到以下错误:
Error downloading modules: Error loading modules: error downloading 'ssh://git@bitbucket.org:<username>/terraform-modules.git': /usr/local/bin/git exited with 128: Cloning into '.terraform/modules/caf541f5e5ccbb1d204bce3b94091014'...
ssh: Could not resolve hostname bitbucket.org:<username>: nodename nor servname provided, or not known
fatal: Could not read from remote repository.使用git clone克隆存储库是可行的。我尝试将TF_LOG环境变量设置为TRACE,看看这是否会给我带来更多的洞察力,但没有帮助。
你知道为什么这个失败了吗?
发布于 2019-05-27 05:36:44
将ssh://git@bitbucket.org和username/repo之间的冒号改为斜杠:
ssh://git@bitbucket.org/username/repo
在这种格式中,冒号表示替代端口-如果您想执行ssh://git@altssh.bitbucket.org:443/username/repo,则非常有用,类似于为其他协议指定替代端口的方式。
发布于 2019-05-27 01:25:17
在尝试访问私有存储库时,hashicorp/terraform issue 12696也会出现类似的错误。
至少,尝试并设置git config --global core.sshCommand "ssh -Tvv",以便查看Terraform在git clone过程中实际使用的私钥。
https://stackoverflow.com/questions/56314628
复制相似问题