You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terraform init should use the right ssh key based on the included git configuration.
Actual Behavior
For some reason terraform is always looking for the default id_rsa file even if git config -l says otherwise.
When ~/.ssh/id_rsa does not exist:
╷
│ Error: Failed to download module
│
│ Could not download module "eks" (main.tf:54) source code from
│ "git::ssh://[email protected]/xxx/terraform_shared_modules.git": error downloading
│ 'ssh://[email protected]/xxx/terraform_shared_modules.git': /usr/bin/git exited with 128: Cloning into
│ '.terraform/modules/eks'...
│ [email protected]: Permission denied (publickey).
│ fatal: Could not read from remote repository.
│
│ Please make sure you have the correct access rights
│ and the repository exists.
│
╵
When ~/.ssh/id_rsa does exist but belongs to a different Github account that does not have access to the private repository:
╷
│ Error: Failed to download module
│
│ Could not download module "eks" (main.tf:54) source code from
│ "git::ssh://[email protected]/xxx/terraform_shared_modules.git": error downloading
│ 'ssh://[email protected]/xxx/terraform_shared_modules.git': /usr/bin/git exited with 128: Cloning into
│ '.terraform/modules/eks'...
│ ERROR: Repository not found.
│ fatal: Could not read from remote repository.
│
│ Please make sure you have the correct access rights
│ and the repository exists.
│
╵
Steps to Reproduce
terraform init
Additional Context
The repository where the module exists is private.
Unsure if the issue is caused in go-getter or in terraform, related pieces of code:
And it clones without issue, so there seems to be some truth to @mkielar 's comment when it mentions that go-getter git does not use the local .git/config or .gitconfig.
Unrelated to the actual issue setting export GIT_SSH_COMMAND="ssh -i ~/.ssh/work_id_rsa" for example, does work but I would guess if git runs as expected the above issue should work as well.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
Terraform Configuration Files
Debug Output
Expected Behavior
Terraform init should use the right ssh key based on the included git configuration.
Actual Behavior
For some reason terraform is always looking for the default id_rsa file even if
git config -l
says otherwise.When ~/.ssh/id_rsa does not exist:
When ~/.ssh/id_rsa does exist but belongs to a different Github account that does not have access to the private repository:
Steps to Reproduce
terraform init
Additional Context
The repository where the module exists is private.
Unsure if the issue is caused in go-getter or in terraform, related pieces of code:
terraform/internal/getmodules/installer.go
Line 43 in 64635ed
I created a simple script to test local behavior of the os/exec/Command:
And it clones without issue, so there seems to be some truth to @mkielar 's comment when it mentions that
go-getter git
does not use the local.git/config
or.gitconfig
.Related global .gitconfig:
Unrelated to the actual issue setting
export GIT_SSH_COMMAND="ssh -i ~/.ssh/work_id_rsa"
for example, does work but I would guess if git runs as expected the above issue should work as well.References
The text was updated successfully, but these errors were encountered: