Terraform: Unable to reference modules nested within an SSH git repository

Created on 17 Mar 2015  ·  4Comments  ·  Source: hashicorp/terraform

Terraform has very nice syntax for referencing modules in a Github repository. Namely, you specify the git repository and append the sub-directory: github.com/org/repo/some-module.

Unfortunately, Terraform defaults to using the HTTPS transport and it isn't clear how to get it to use SSH. Switching to the long-form git::ssh://github.com:org/repo/some-module does not work because Terraform uses the wrong repository address. Running strace -f -s 10000 -e trace=execve terraform get yields the following line (other lines excluded for brevity):

[pid  5296] execve("/usr/bin/git", ["git", "clone", "ssh://github.com:org/repo/some-module", ".terraform/modules/f25adaa051a5cc115e4740290b935b2a"]

Any thoughts?

bug core

Most helpful comment

👍 you can reference directories inside of a git repo using //. Example:

github.com/org/repo//modules/stack1

All 4 comments

Yes, this is tricky, but read about double-slashes here: https://terraform.io/docs/modules/sources.html

I'm baffled with how I could have missed this in the documentation. :disappointed:

👍 you can reference directories inside of a git repo using //. Example:

github.com/org/repo//modules/stack1

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.

Was this page helpful?
0 / 5 - 0 ratings