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
Best Answer
Here's a working example from one of my projects:
Here, the branch name is "main", but note that it could be a tag or other reference.