【发布时间】:2020-10-31 09:24:00
【问题描述】:
我查看了 Azure rm 的 Terraform 数据源,但找不到我要查找的内容。如何使用 Terraform 数据源获取 azure Managed Identity ID?
【问题讨论】:
我查看了 Azure rm 的 Terraform 数据源,但找不到我要查找的内容。如何使用 Terraform 数据源获取 azure Managed Identity ID?
【问题讨论】:
托管身份有两种类型:系统分配和用户分配。
某些 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
}
结果
【讨论】: