无法从azure repo(私有repo)下载terraform模块

无法从azure repo(私有repo)下载terraform模块,terraform,terraform-provider-azure,azure-repos,Terraform,Terraform Provider Azure,Azure Repos,我的terraform模块回购位置如下: https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster source = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyp

我的terraform模块回购位置如下:

https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster
source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git"
source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git?ref=<branch>"
我在根级别有三个目录/模块,即compute、resourcegroup和sqlserver。 但是,当我运行terraforminit时。terraform无法下载所需的模块

main.tf

module "app_vms" {
  source                = "https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster"
  rg_name               = var.resource_group_name
  location              = module.resource_group.external_rg_location
  vnet_name             = var.virtual_network_name
  subnet_name           = var.sql_subnet_name
  app_nsg               = var.application_nsg
  vm_count              = var.count_vm
  base_hostname         = var.app_host_basename
  sto_acc_suffix        = var.storage_account_suffix
  vm_size               = var.virtual_machine_size
  vm_publisher          = var.virtual_machine_image_publisher
  vm_offer              = var.virtual_machine_image_offer
  vm_sku                = var.virtual_machine_image_sku
  vm_img_version        = var.virtual_machine_image_version
  username              = var.username
  password              = var.password
  allowed_source_ips    = var.ip_list
}

module "resource_group" {
  source                = "https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fresourcegroup&version=GBmaster"
  rg_name               = "test_rg"
}

module "azure_paas_sqlserver" {
  source                = "https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fsqlserver&version=GBmaster"  
}
它给了我一系列的错误,如下所示:(示例仅给出了并非所有的错误,因为它们是相同的)

我试图删除https://部分,但没有成功。回购协议需要用户名和密码才能登录

想知道我是否应该在github进行公开回购?但在组织内部推动的是使用Azure Repos


发表第一条评论


谢谢你的引导,我试过了,但还是没有魅力

我的源url现在如下所示

  source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster"
我得到以下错误信息:

Error: Failed to download module

Could not download module "sql_vms" (main.tf:1) source code from
"git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster":
error downloading
'https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster':
/usr/bin/git exited with 128: Cloning into '.terraform/modules/sql_vms'...
fatal: repository
'https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster/'
not found
在这里:

teamabc.visuastudio.com是azure devops的父url

dummyproject项目名称

Error: Failed to download module

Could not download module "sql_vms" (main.tf:1) source code from
"git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git":
error downloading
'https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git':
/usr/bin/git exited with 128: Cloning into '.terraform/modules/sql_vms'...
fatal: repository
'https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git/'
not found
在Charles回复后

Error: Failed to download module

Could not download module "sql_vms" (main.tf:1) source code from
"git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git":
error downloading
'https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git':
/usr/bin/git exited with 128: Cloning into '.terraform/modules/sql_vms'...
fatal: repository
'https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git/'
not found
您可以看一下,URL应该是Git URL。最后,它应该是这样的:

https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster
source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git"
source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git?ref=<branch>"
或者,您可以从Git存储库中选择一个分支,如下所示:

https://teamabc.visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster
source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git"
source                = "git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform-modules?path=%2Fcompute&version=GBmaster.git?ref=<branch>"
source=“git::https://teamabc:lfithww4xpp4eksvoimgzkpi3ugu6xvrkf26mfq3jth3642jgyoa@visualstudio.com/dummyproject/_git/terraform modules?路径=%2Fcompute&version=GBmaster.git?参考=”
最后,通过以下命令使其工作:

git::https://<PAT TOKEN>@<Azure DevOps URL>/DefaultCollection/<PROJECT NAME>/_git/<REPO NAME>//<sub directory>
git::https://@/DefaultCollection/\u git///

您试过了吗?先生,正如您在我的更新中看到的那样。我尝试了以.git结尾的url。仍然不起作用。下面的错误。先生,我已经在问题的底部添加了日志。谢谢。通过下面的git::https://@/DefaultCollection//\u git///问题更多的是本地VM上的源url,而不是Azure Pipelines代理上的源url。这个解决方案在Azure管道上也可以工作,但是PAT令牌是硬编码的,这不是一个好主意。有没有一种方法可以在不硬编码PAT令牌的情况下使其工作?