diff --git a/code/infra/alerts.tf b/code/infra/alerts.tf new file mode 100644 index 0000000..ed2c8fc --- /dev/null +++ b/code/infra/alerts.tf @@ -0,0 +1,34 @@ +resource "azurerm_monitor_activity_log_alert" "monitor_activity_log_alert_service_health" { + name = "${local.prefix}-alert-servicehealth" + resource_group_name = azurerm_resource_group.logging_rg.name + tags = var.tags + + enabled = true + description = "Alerts about service health and maintenance events." + scopes = [ + data.azurerm_subscription.current.id + ] + action { + action_group_id = azurerm_monitor_action_group.monitor_action_group.id + webhook_properties = { + "alert-type" = "service-health", + "location" = var.location + "environment" = var.environment + "subscription" = data.azurerm_client_config.current.subscription_id + "severity" = "Info" + } + } + criteria { + category = "ServiceHealth" + service_health { + events = [ + "Incident", + "Maintenance" + ] + locations = [ + "Global", + data.azurerm_location.current.display_name + ] + } + } +} diff --git a/code/infra/data.tf b/code/infra/data.tf index 5285bdf..66f3212 100644 --- a/code/infra/data.tf +++ b/code/infra/data.tf @@ -1,5 +1,11 @@ data "azurerm_client_config" "current" {} +data "azurerm_subscription" "current" {} + +data "azurerm_location" "current" { + location = var.location +} + data "azurerm_virtual_network" "virtual_network" { name = local.virtual_network.name resource_group_name = local.virtual_network.resource_group_name