azure - 如何从 terraform 获取 Azure Security Insights 对象 ID?

标签 azure terraform

我需要在 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 应用程序,如下所示:

enter image description here

当我运行下面的 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
}

回应:

enter image description here

关于azure - 如何从 terraform 获取 Azure Security Insights 对象 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76236611/

相关文章:

terraform - 在 Terraform 中提取代码块作为变量

Terraform - 在 Azure 上配置静态 IP 地址

azure - 使用azure服务总线,如何将单个消息发布到多个队列?

maven - 如何在Android Studio中将Azure存储库添加到Android项目中

azure - ARM 脚本无服务器 SignalR 以及函数应用程序的上游设置

azure - Terraform - 列表到字符串以创建 azure 订阅列表

google-cloud-platform - googleapi : Error 400: Precondition check failed.,通过 Terraform 创建 Cloud Composer 环境时失败了前提条件

用于列出代理池和运行的作业的 Azure CLI 命令

Azure 机器学习 - CORS

amazon-web-services - 用于更新现有启动模板的 Terraform 配置