我需要在 Azure Security Insights 应用程序上添加 Azure Sentinel Automation Contributor 角色。为此,如何通过 terraform 获取 Azure Active Directory 中的企业应用程序中存在的 Azure Security Insights 应用程序的 objectId?
resource "azurerm_role_assignment" "sentinel_contributor" {
scope = "/subscriptions/<subId>/resourceGroups/<rg>"
// role_definition_id = azurerm_role_definition.sentinelcontributor.id
role_definition_name = "Azure Sentinel Contributor"
principal_id = "3367a746-xxx18686"#objectid of azure security insights app
}
最佳答案
要通过 terraform 获取 Azure Active Directory 企业应用程序中存在的 Azure Security Insights 应用程序的 objectId
,您可以使用以下代码:
data "azuread_service_principal" "security_insights_app" {
display_name = "Azure Security Insights"
}
output "security_insights_app_object_id" {
value = data.azuread_service_principal.security_insights_app.object_id
}
我的租户的企业应用程序中有 Azure Security Insights 应用程序,如下所示:
当我运行下面的 terraform 代码时,我成功获得了 Azure Security Insights 应用程序的 ObjectID
响应,如下所示:
data "azuread_service_principal" "security_insights_app" {
display_name = "Azure Security Insights"
}
output "security_insights_app_object_id" {
value = data.azuread_service_principal.security_insights_app.object_id
}
回应:
关于azure - 如何从 terraform 获取 Azure Security Insights 对象 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76236611/