2

I need help with sourcing terraform modules from a gitlab repository with multiple modules in it like ec2, vpc etc. I have two branches in module repo - develop and main. I tried all the ways below but got an error. I am sourcing something like below. I need ssh only, not https.

source = "git::ssh://[email protected]:repo_name/modules.git//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git/ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules/ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules//ec2?ref=develop"
"git::ssh://[email protected]/repo_name/modules//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git//ec2"
"git::ssh://[email protected]:repo_name/modules.git?ref=ec2"
"git::ssh://[email protected]:repo_name/modules.git?ref=develop//ec2"
"git::ssh://[email protected]:repo_name/modules.git/develop/ec2"
"git::ssh://[email protected]:repo_name/modules.git//ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules.git/develop/ec2"
"git::ssh://[email protected]:repo_name/modules/ec2?ref=develop"
"git::ssh://[email protected]:repo_name/modules//ec2"

This is the error I am getting

│ 
│ Module "ec2" (declared at compute/main.tf line 1)
│ has invalid source address
│ "git::ssh://[email protected]:repo_name/modules//ec2": Terraform
│ cannot detect a supported external module source type for

1 Answer 1

3

Here's a working example from one of my projects:

module "sql_cluster" {
  source = "git::ssh://[email protected]/foo/bar/tf-modules.git//data/database-cluster?ref=main"

Here, the branch name is "main", but note that it could be a tag or other reference.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .