【发布时间】:2021-05-04 21:17:19
【问题描述】:
为了使
local-exec配置程序能够成功运行azcli 命令,需要对以下 terraform 语法进行哪些具体更改?
这是导致问题的 terraform 代码:
resource "azuredevops_git_repository" "repository" {
project_id = data.azuredevops_project.p.id
name = var.repoName
initialization {
init_type = "Uninitialized"
}
provisioner "local-exec" {
working_dir = "C:\\projects\\acm\\Apr2021\\config-outside-acm-path\\vars\\deleteThis\\"
command = "az repos import create --git-source-url \"${var.sourceRepo}\" --repository \"${azuredevops_git_repository.repository.name}\" --organization \"${var.azdoOrgServiceURL}\" --project \"${var.projectName}\""
}
}
这是我们得到的错误:
Error: Error running command
'az repos import create --git-source-url "https://github.com/PublicGitHubAccount/public-github-repo.git"
--repository "private-azure-repo" --organization "https://dev.azure.com/OurValidOrganizationName"
--project "SampleProject"'
: exit status 1.
Output: --organization must be specified.
The value should be the URI of your Azure DevOps organization, for example: https://dev.azure.com/MyOrganization/ or your Azure DevOps Server organization.
You can set a default value by running: az devops configure --defaults organization=https://dev.azure.com/MyOrganization/.
For auto detection to work (--detect true), you must be in a local Git directory that has a "remote" referencing a Azure DevOps or Azure DevOps Server repository.
当我们从错误消息中复制命令并通过 Python 程序将该命令作为 shell 命令运行时,该命令可以正常运行而不会出现错误。以下是使用 Python shell 执行时正确运行的命令:
'az repos import create --git-source-url "https://github.com/PublicGitHubAccount/public-github-repo.git"
--repository "private-azure-repo" --organization "https://dev.azure.com/OurValidOrganizationName"
--project "SampleProject"'
因此,问题在于 terraform 无法看到 --organization 变量,即使您可以从上面看到 terraform 正确地插入了字符串。
【问题讨论】:
标签: azure azure-devops terraform terraform-provider-azure