Permission Error with Terraform while cloning a Git module

Hi, we have a terraform module that has its source in a separate private git repo e.g.

module “vm” {
source = “git::https://gitlab.com/pathtomodule/my-tf-module-vm.git
}

We have stood up our own self hosted runners.

Running terraform init in the CI pipeline was working fine. The module would be cloned as expected.
Then it stopped working with this error (I’ve redacted some information as its sensitive):

Error: Failed to download module

Could not download module “vm”

source code from
git::https://gitlab.com/pathtomodule/my-tf-module-vm.git:
error downloading

/usr/bin/git exited with 128: Cloning into

No such device or address

Can someone pls tell me if there is anything specific on the runner we need to configured to get this working? We’ve read through

We’re assuming that the runner supported this Terraform statement " Terraform installs modules from Git repositories by running git clone , and so it will respect any local Git configuration set on your system, including credentials. To access a non-public Git repository, configure Git with suitable credentials for that repository"

but we haven’t found RCA as to why it is now not working.

Are you still have this error?, Did you solve it?

We recently have the same issue with our private gitlab-runner, but using it ssh as the way to download ours source code:

In the main terraform module code we have:

 source = git@gitlab.com/_the_project_.git

When gitlab take it, it appear:

 error downloading
│ 'ssh://git@gitlab.com/_the_project_.git
│ /usr/bin/git exited with 128: Cloning into
│git@gitlab.com: Permission denied (publickey,keyboard-interactive).
│ fatal: Could not read from remote repository.
│ 
│ Please make sure you have the correct access rights
│ and the repository exists.

But locally (on our gitlab-runner), We don’t have that problem, even do can make:

rm -rf .terraform && terraform init && terraform _what_ever_

So, We can download the whole project.

If you interested, The workaround was creating a gitlab credential token and using https instead ssh, so now it looks like this:

source = git::https://gitlab.com/_the_project_.git

but as I mentioned We didn’t solved the problem, this issue it still exist.

BTW, We are using:

  • Running with gitlab-runner 13.11.0 (7f7a4bb0)
  • Terraform v0.15.3 on linux_amd64