# identity-provider-signals / m365 / t1 "Standard" # # The quick start's four alerts and the silence alert, with named admins # left out and each rule reading under its own identity. It adds an alert on # a guest added to a team, and saved queries for working the case. One more # alert fires when a user downloads or syncs more SharePoint and OneDrive # files in an hour than a number you set. # # detections.tf has the alerts, and queries.tf the saved queries. # # Before you start: auditing must be on in the tenant # (Get-AdminAuditLogConfig | Format-List UnifiedAuditLogIngestionEnabled # reads True). Whoever runs apply needs Global Administrator or Security # Administrator in the tenant, and Owner or User Access Administrator on the # resource group, because each alert is given a reader role on the workspace. # # Turning on Sentinel puts every table in the workspace under Sentinel # billing, so keep this workspace for these records alone. The workspace # uses Microsoft-managed encryption; a key of your own needs a dedicated # cluster, which is priced for 100 GB a day and more. data "azurerm_client_config" "current" {} 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" "m365" { name = "law-m365-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 } resource "azurerm_sentinel_log_analytics_workspace_onboarding" "m365" { workspace_id = azurerm_log_analytics_workspace.m365.id } # The connector reads the tenant that runs apply; Azure does not support # another tenant here. resource "azurerm_sentinel_data_connector_office_365" "m365" { name = "m365-audit" log_analytics_workspace_id = azurerm_sentinel_log_analytics_workspace_onboarding.m365.workspace_id tenant_id = data.azurerm_client_config.current.tenant_id exchange_enabled = true sharepoint_enabled = true teams_enabled = true } resource "azurerm_monitor_action_group" "m365" { name = "m365-signals" resource_group_name = data.azurerm_resource_group.security.name short_name = "m365" 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 } } }