My terraform module is in a private bitbucket repo accessed via an ssh key.
I don't know what git command terraform runs or how to change auth, but it seems to be using a different ssh config.
this is my .tf
file:
module "sdfsdfs" {
source = "git::ssh://bitbucket.org/mycomp/my-module-root//submodule"
}
I'm running this in a jenkins pipeline and I am editing the ssh config to use a specific key. I have proven this works:
sshagent (credentials: ['my-ssh-key']) {
bat 'git clone git@bitbucket.org:mycomp/my-module.git'
}
The ssh config is modified correctly and uses my key store in jenkins.
I don't know what terraform is actually running to pull from git repo but it's not respecting the ssh config:
sshagent (credentials: ['my-ssh-key']) {
bat 'terraform init'
}
I get this error:
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.
What is terraform doing or failing to do here? I want to configure this for this session only, so setting a global ssh config for my jenkins server is not possible.