Score:0

Terraform source Gitlab module

cn flag

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
Score:0
th flag

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.

Score:0
eg flag

This worked for me for a private repository in the company gitlab https://wahlnetwork.com/2020/08/11/using-private-git-repositories-as-terraform-modules/

anx avatar
fr flag
anx
We highly prefer answers that *contain* not merely *reference* the solution.
ph flag
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/536615)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.