TFE and Github auth issue

Hi,
I just got my sandbox TFE instance up and running and am now testing out its capabilities.

I am trying a very basic implementation, setting up a workspace, integrating with a git repo, and running a plan against a script.
This script runs fine if I execute through the terraform cli.
In TFE, I have tried this using version 11.14 and 12.2.
The specific line that is throwing the error: source = “git::https://github.com/corelogic/terraform-gcp-compute?ref=v4.0.2
Error: fatal: could not read Username for ‘https://github.com’: No such device or address

I will paste the entire log below…
This appears to be an auth issue with Git, but it is not making sense to me.
As I stated before, this runs fine on my local using the CLI. I have the same level of access to the primary repo and the module repo. TFE can access and download the initial Git repo. TFE fails with the error when pulling the module repo.

I have tried to play with the workspace settings with no change.

thanks…

Full log:
Terraform v0.11.14

Configuring remote state backend…
Initializing Terraform configuration…

Setup failed: Failed terraform init (exit 1):

Output:
2019/08/29 22:39:57 [DEBUG] Using modified User-Agent: Terraform/0.11.14 PTFE/b5916fe
e[0me[1mInitializing modules…e[0m

  • module.impersonation-token
    Getting source “…/…/…/…/modules/non_app/other/impersonate”
  • module.primaryad
    Getting source “…/…/…/…/modules/app/compute/activedirectory”
  • module.primaryad.dcs
    Getting source “…/…/…/…/modules/non_app/compute/managed_instance_group”
  • module.primaryad.dcs.google_managed_instance
    Getting source “git::https://github.com/corelogic/terraform-gcp-compute?ref=v4.0.2
    e[31mError downloading modules: Error loading modules: error downloading ‘https://github.com/corelogic/terraform-gcp-compute?ref=v4.0.2’: /usr/bin/git exited with 128: Cloning into ‘.terraform/modules/8aff81c006c9580a42bbd49d60814361’…
    fatal: could not read Username for ‘https://github.com’: No such device or address
    e[0me[0m

Hi @bgoodman-clgx!

Indeed, this does seem to be a Git problem rather than a Terraform problem. :frowning:

I believe that error can arise if you have Git configured to use a credentials helper and that helper program fails when Git runs it to ask for credentials. Sadly, I don’t have direct experience with that sort of setup so I can’t offer any direct advice about it, but maybe you can check which credentials helper you have configured (if any) and that would give you some keywords to search for to research further.

If you have SSH authentication already configured for GitHub on your system, another option might be to avoid HTTPS access altogether by configuring Git to prefer SSH when accessing GitHub:

git config --global url."git@github.com:".insteadOf "https://github.com/"

After running the above, Git will use SSH instead of HTTPS whenever it’s asked to fetch from a source starting with https://github.com/, which would stop Git trying to use a credentials helper because it will delegate authentication to the SSH client instead.

1 Like

Thanks for your response. There are a few key items that I would like clarity upon.
This does seem that this is an auth issue with Github…
However, this is specifically an auth issue between Github and Terraform Enterprise. This in not an issue outside of that scope.
Perhaps I can get more information about the mechanics of the TFE and Github interaction. From my perspective, configuring the webhook using the OAuth set up in Git should be adequate for all auth between Github and TFE. If that is not the case, then I would like to get more detailed information on the expectations of setting up the integration. Is there a limitation of the frequency of auth? Since TFE can initially contact Git and pull the scripts, and the modules are also under the same security policy, wouldn’t it follow that TFE should be able to pull the module repo too?
I am also confident that this is caused by the interaction of TFE and Github. I have no issues running this script outside of TFE.

Thanks in advance for your response.

Hi @bgoodman-clgx!

Sorry I didn’t notice on the first read that you were talking about Git running inside Terraform Enterprise.

This forum is mainly focused on the Terraform language and using the Terraform CLI directly, so there isn’t as much direct Terraform Cloud and Terraform Enterprise expertise here right now. You’d probably get a better answer to this particular question by reaching out to Terraform Enterprise customer support.