Azure Devops terraform modules sourcing

Issue

I’ve been researching and going back and forth on a lot of topics, yet I may have not understood clearly so I’m looking for guidance.
I have an azure devops account where I currently have two projects.
Project A
Project B

In project A I created 3 repositories – each repository is a terraform module.
Project A – repostitories: 1) virtual network module 2) resource group module 3) virtual machine module

Project B is where I have my pipeline and my main.tf where I would like to call the module using the source.

I would not like to use scripts to pre-download modules, I’d like to use the format alongside with release tags for different releases of the same module.

  source = "git::https://dev.azure.com/loredan6/Terraform%20Code/_git/ResourceGroup"
  # Resource Group Variables

  az_rg_name     = "ResourceGroup-Name"
  az_rg_location = "UK South"

  az_tags = {
    Environment   = "Development"
    CostCenter    = "Department"
    ResourceOwner = "Example Owner"
    Project       = "Project Name"
    Role          = "Resource Group"
  }
}
Initializing modules...
Downloading git::https://dev.azure.com/loredan6/Terraform%20Code/_git/ResourceGroup for az-resource-group...
╷
│ Error: Failed to download module
│ 
│ Could not download module "az-resource-group" (main.tf:20) source code from
│ "git::https://dev.azure.com/loredan6/Terraform%20Code/_git/ResourceGroup":
│ error downloading
│ 'https://dev.azure.com/loredan6/Terraform%20Code/_git/ResourceGroup':
│ /usr/bin/git exited with 128: Cloning into
│ '.terraform/modules/az-resource-group'...
│ fatal: could not read Username for 'https://dev.azure.com': terminal
│ prompts disabled

The error is the one above. Any suggestions or a good guide on how to achieve this? is this even possible?

Solution

Looks like the issue was related to the association of the System.AccessToken which wasn’t passed on properly. after figuring that out , everything works perfectly fine. indeed authentication was the primary issue.

Answered By – Călimanu Loredan

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published