简体   繁体   English

使用bitbucket git存储库源通过SSH下载模块时出现的问题

[英]Issues using bitbucket git repository source for downloading a module over SSH

When calling a module over from a local source everything went alright, however I decided to refactor the Terraform code to use a git repository for modules. 从本地源调用模块时,一切正常,但是我决定重构Terraform代码以将git存储库用于模块。

I created a new repository in our BitBucket account with the name terraform-modules, and refactored the source attribute of the modules to have the following structure: 我在我们的BitBucket帐户中创建了一个名称为terraform-modules的新存储库,并将模块的source属性重构为以下结构:

source     = "git::ssh://git@bitbucket.org:carepaydev/terraform-modules.git//modules/iam/iam_roles/assumable_role"

When calling terraform init I get the following error: 调用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.

Cloning the repository using git clone does work. 使用git clone克隆存储库确实可行。 I tried setting the TF_LOG env var to TRACE to see if that would give me more insight, but that did not help. 我尝试将TF_LOG env var设置为TRACE以查看是否可以为我提供更多的见解,但这无济于事。

Any clue why this fails? 任何线索为什么失败了?

Change the colon between ssh://git@bitbucket.org and username/repo to a slash: ssh://git@bitbucket.orgusername/repo之间的冒号更改为斜杠:

ssh://git@bitbucket.org/username/repo

In that format, the colon indicates an alternate port - useful if you want to do ssh://git@altssh.bitbucket.org:443/username/repo , and similar to how you'd specify an alternate port for other protocols like HTTP. 以这种格式,冒号表示备用端口-如果您想执行ssh://git@altssh.bitbucket.org:443/username/repo ,则很有用,类似于您为其他协议指定备用端口的方式,例如HTTP。

You have a similar error with hashicorp/terraform issue 12696 , when trying to access a private repository. 尝试访问私有存储库时, hashicorp / terraform问题12696也有类似错误。

At least, try and set git config --global core.sshCommand "ssh -Tvv" , in order to see what private key is actually used by Terraform durong the git clone process. 至少尝试设置git config --global core.sshCommand "ssh -Tvv" ,以查看git clone过程中Terraform durong实际使用了哪些私钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM