繁体   English   中英

Terraform Azuread 提供商授权错误

[英]Terraform Azuread provider Authorizer Error

我的 GitLab CI/CD 管道抛出 Terraform Azuread 提供商授权错误,这已成为我的主要障碍,我根本找不到绕过它的方法。

我的 Terraform 配置包括一个data.tf文件,该文件具有以下单行条目:

data "azuread_client_config" "current" {}

我还有一个provider.tf文件,其内容包括以下 azuread 提供程序块:

provider "azuread" {
   tenant_id = "#TenantID#"
   use_cli = "false"
}

运行 GitLab CI/CD 管道,抛出以下错误:

Error: no Authorizer could be configured, please check your configuration

with provider ["registry.terraform.io/hashicorp/azuread"],
on provider.tf line 29, in provider "azuread":
29: provider "azuread" {

如果我从我的 terraform 配置中排除 data.tf 文件或注释掉它的单行条目,管道运行时不会抛出任何错误。 在包含 data.tf 文件后,我做错了什么,或者我需要做什么才能使管道成功运行?

数据来源:azuread_client_config

使用此数据源访问 AzureAD 提供程序的配置。

#这是在 Terraform 通过 Azure CLI 进行身份验证时

data "azuread_client_config" "current" {}

output "object_id" {
  value = data.azuread_client_config.current.object_id
}

#配置 Azure Active Directory Provider

provider "azuread" {

  # NOTE: Environment Variables can also be used for Service Principal authentication

  # client_id     = "..."
  # client_secret = "..."
  # tenant_id     = "..."
}

因此,如果您在 provider.tf 文件中使用provider azuread {} ,建议您从data.tf文件中删除data "azuread_client_config" "current" {}行。 因为您已经在使用 Service Principle 进行身份验证,所以没有必要使用azuread 的数据源

您还可以参考此文档,了解 Azure Active Directory Provider 支持的Data SourcesResources

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM