0
votes

Is there any way to load terraform modules with private git repo? I've been planning to implement it with an Azure DevOps pipeline so I think that using it with ssh key its not an option.

Any ideas/suggestions on how I could achieve this goal?

Thanks in advance

1
Where is the private git repo hosted (GitHub, GitLab, BitBucket, Azure Repos)? The answer here is pretty heavily dependenct on that as the generic solution is way less convenient and way more awkward. ā€“ Alain O'Dea
Hello , Iā€™m using Azure Repos ā€“ user3573246

1 Answers

1
votes

You can load the Terraform modules from any place that you can get it where you execute the Terraform command. I see you use the Azure Repos and you want to execute the Terraform in the Pipeline. So you can use the relative path to load the modules. For example, your folder structure like this:

enter image description here

And you create the VM module in the VM folder and network in the network folder. And then you want to load the modules in the terraform folder within the main.tf file, then you can add code in the main.tf file like this:

module "vm" {
  source = "modules/vm"

  ...
}

module "network" {
  source = "modules.network"

  ...
}

It will load the modules from the path you set for the source. If you have any more questions, please give me the messages to let me know. I'm glad to give you a favor.