我的 terraform 模块位于通过 ssh 密钥访问的私有 bitbucket 存储库中。
我不知道 git 命令 terraform 运行什么或如何更改身份验证,但它似乎使用不同的 ssh 配置。
这是我的.tf
file:
module "sdfsdfs" {
source = "git::ssh://bitbucket.org/mycomp/my-module-root//submodule"
}
我正在 jenkins 管道中运行它,并且正在编辑 ssh 配置以使用特定的密钥。我已经证明这是有效的:
sshagent (credentials: ['my-ssh-key']) {
bat 'git clone [email protected] /cdn-cgi/l/email-protection:mycomp/my-module.git'
}
ssh 配置已正确修改并使用我在 jenkins 中的密钥存储。
我不知道 terraform 实际上正在运行什么来从 git repo 中提取,但它不尊重 ssh 配置:
sshagent (credentials: ['my-ssh-key']) {
bat 'terraform init'
}
我收到此错误:
C:\Program Files\Git\cmd\git.exe exited with 128: Cloning into
'.terraform\modules\c760b746e09bd59ba86aae13dc9e9959'...
Permission denied (publickey).
fatal: Could not read from remote repository.
terraform 在这里做什么或没做什么?我只想为此会话配置此选项,因此无法为我的 jenkins 服务器设置全局 ssh 配置。