【问题标题】:Get azure Managed Identity ID with Terraform使用 Terraform 获取 azure Managed Identity ID
【发布时间】:2020-10-31 09:24:00
【问题描述】:

我查看了 Azure rm 的 Terraform 数据源,但找不到我要查找的内容。如何使用 Terraform 数据源获取 azure Managed Identity ID?

【问题讨论】:

    标签: terraform-provider-azure


    【解决方案1】:

    托管身份有两种类型:系统分配用户分配

    某些 Azure 服务允许您直接在服务实例上启用托管标识。例如,您可以使用 identity 块在 Azure VM 上启用托管标识。此外,您可以导出identity 属性并通过${azurerm_virtual_machine.example.identity.0.principal_id} 访问主体ID。

    如果您使用此data source 访问有关现有虚拟机的信息。您可以通过identity 块导出以下内容。

    output "identity" {
       value = data.azurerm_virtual_machine.example.identity
    }
       
    output "identity_identity_ids" {
       value = data.azurerm_virtual_machine.example.identity.*.identity_ids
    }
    
    output "identity_principal_id" {
      value = data.azurerm_virtual_machine.example.identity.*.principal_id
    }
    
    output "identity_tenant_id"{
       value = data.azurerm_virtual_machine.example.identity.*.tenant_id
    }
    
    output "identity_type" {
        value = data.azurerm_virtual_machine.example.identity.*.type
    }
    

    结果

    【讨论】:

      猜你喜欢
      • 2021-01-27
      • 1970-01-01
      • 2021-01-02
      • 2020-03-26
      • 2015-07-30
      • 2019-01-26
      • 1970-01-01
      • 2020-01-05
      • 1970-01-01
      相关资源
      最近更新 更多