将服务连接转换为工作负载身份后 Terraform 无法运行

问题描述 投票:0回答:1

我已将服务连接转换为工作负载身份,现在我收到以下授权错误:

enter image description here

我根据文档添加了 use_oidc = true 选项:
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/service_principal_oidc

enter image description here

我已将 use_oidc = true 选项添加到提供程序“azurerm”部分。我还尝试按照文档将其添加到后端,但没有任何配置对我来说是成功的。有人解决这个问题了吗?非常感谢任何帮助:)

PS,我正在使用 TerraformTaskV4@4 任务

enter image description here

azure terraform azure-rm workload-identity
1个回答
0
投票

要使用服务主体进行身份验证,您需要在后端块中提供所需的参数

client_id
client_secret
subscription_id
tenant_id

enter image description here

    terraform {
      backend "azurerm" {
        resource_group_name  = "v-vallepuv-Mindtree"          
        storage_account_name = "venkatstorage"                            
        container_name       = "venkat"                               
        key                  = "prod.terraform.tfstate"                
        use_oidc             = true                              
        client_id            = "xxxxxx" 
        subscription_id      = "xxxxx"  
        tenant_id            = "xxxxxxxx"
        client_secret        = "xxxxxxx"  
        use_azuread_auth     = true 
                                          
      }
    }
    
    provider "azurerm"{
        features {}
        skip_provider_registration = "true"
        subscription_id      = "1234566-c5b6-44fb-b5ba-2b83a074c23f"
        use_oidc        = true   
        use_cli         = false 
    }

输出:

enter image description here

如果您使用任何管道,请确保按照quadroid

Stack Link

在环境中设置服务主体详细信息

参考:堆栈链接1

在 Terraform 中配置服务主体

© www.soinside.com 2019 - 2024. All rights reserved.