From a51192653f9bdfe6ee0c3459c04c29f82fd22133 Mon Sep 17 00:00:00 2001 From: Fraser Molyneux Date: Mon, 23 Dec 2024 22:27:24 +0000 Subject: [PATCH] Adding action group --- terraform/data.monitor_action_groups.tf | 45 +++++++++++++++++++++++++ terraform/resource_health_alerts.tf | 4 +++ 2 files changed, 49 insertions(+) create mode 100644 terraform/data.monitor_action_groups.tf diff --git a/terraform/data.monitor_action_groups.tf b/terraform/data.monitor_action_groups.tf new file mode 100644 index 0000000..660bb83 --- /dev/null +++ b/terraform/data.monitor_action_groups.tf @@ -0,0 +1,45 @@ +provider "azurerm" { + alias = "azure_monitor" + subscription_id = var.environment == "prd" ? "7760848c-794d-4a19-8cb2-52f71a21ac2b" : "d68448b0-9947-46d7-8771-baa331a3063a" + features {} + storage_use_azuread = true +} + +locals { + azure_monitor_resource_group = "rg-platform-monitoring-${var.environment}-uksouth" +} + +data "azurerm_monitor_action_group" "critical" { + provider = azurerm.azure_monitor + + name = "p0-critical-alerts-${var.environment}" + resource_group_name = local.azure_monitor_resource_group +} + +data "azurerm_monitor_action_group" "high" { + provider = azurerm.azure_monitor + + name = "p1-high-alerts-${var.environment}" + resource_group_name = local.azure_monitor_resource_group +} + +data "azurerm_monitor_action_group" "moderate" { + provider = azurerm.azure_monitor + + name = "p2-moderate-alerts-${var.environment}" + resource_group_name = local.azure_monitor_resource_group +} + +data "azurerm_monitor_action_group" "low" { + provider = azurerm.azure_monitor + + name = "p3-low-alerts-${var.environment}" + resource_group_name = local.azure_monitor_resource_group +} + +data "azurerm_monitor_action_group" "informational" { + provider = azurerm.azure_monitor + + name = "p4-informational-alerts-${var.environment}" + resource_group_name = local.azure_monitor_resource_group +} diff --git a/terraform/resource_health_alerts.tf b/terraform/resource_health_alerts.tf index 627318e..eee5564 100644 --- a/terraform/resource_health_alerts.tf +++ b/terraform/resource_health_alerts.tf @@ -15,5 +15,9 @@ resource "azurerm_monitor_activity_log_alert" "rg_resource_health" { } } + action { + action_group_id = var.environment == "prd" ? data.azurerm_monitor_action_group.critical.id : data.azurerm_monitor_action_group.informational.id + } + tags = var.tags }