# identity-provider-signals / entra / t1 "Standard" # # The quick start's four alerts and the silence alert, with named actors # left out and each rule reading under its own identity. It adds an alert on # any sign-in by an emergency access account, an optional alert on high-risk # sign-ins, and saved queries for working the case. # # detections.tf has the alerts, and queries.tf the saved queries. # # Before you start: Microsoft's guide to these logs in Log Analytics lists # Microsoft Entra ID P1 or P2 as a prerequisite. Whoever runs apply needs at # least the Security Administrator role in Entra ID, and Owner or User Access # Administrator on the resource group, because each alert is given a reader # role on the workspace. # # The workspace uses Microsoft-managed encryption. A key of your own on a # Log Analytics workspace needs a dedicated cluster, which is priced for # 100 GB a day and more. locals { tags = merge({ owner = var.owner environment = var.environment data_classification = "confidential" managed_by = "terraform" }, var.extra_tags) } data "azurerm_resource_group" "security" { name = var.resource_group_name } resource "azurerm_log_analytics_workspace" "entra" { name = "law-entra-signals" location = data.azurerm_resource_group.security.location resource_group_name = data.azurerm_resource_group.security.name sku = "PerGB2018" retention_in_days = var.retention_days # No daily cap. A cap drops events once it is reached, with no alert. daily_quota_gb = -1 tags = local.tags } # Tenant-wide: one setting covers every user and app in the directory. resource "azurerm_monitor_aad_diagnostic_setting" "entra" { name = "entra-signals" log_analytics_workspace_id = azurerm_log_analytics_workspace.entra.id dynamic "enabled_log" { for_each = toset(var.log_categories) content { category = enabled_log.value } } } resource "azurerm_monitor_action_group" "entra" { name = "entra-signals" resource_group_name = data.azurerm_resource_group.security.name short_name = "entra" tags = local.tags dynamic "email_receiver" { for_each = toset(var.alert_emails) content { name = replace(email_receiver.value, "/[^A-Za-z0-9-]/", "-") email_address = email_receiver.value } } }