From b1f3be5977d64b78c84661416310799ab7357287 Mon Sep 17 00:00:00 2001 From: athiththan11 Date: Tue, 5 Nov 2024 23:31:17 +0530 Subject: [PATCH] Add Alert Processing Rule to Suppress Resolved Alerts --- ...nitor_alert_processing_rule_suppression.tf | 26 +++++++++ .../variables.tf | 53 +++++++++++++++++++ .../versions.tf | 20 +++++++ 3 files changed, 99 insertions(+) create mode 100644 modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/monitor_alert_processing_rule_suppression.tf create mode 100644 modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/variables.tf create mode 100644 modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/versions.tf diff --git a/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/monitor_alert_processing_rule_suppression.tf b/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/monitor_alert_processing_rule_suppression.tf new file mode 100644 index 00000000..22e64fce --- /dev/null +++ b/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/monitor_alert_processing_rule_suppression.tf @@ -0,0 +1,26 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved. +# +# This software is the property of WSO2 LLC. and its suppliers, if any. +# Dissemination of any information or reproduction of any material contained +# herein in any form is strictly forbidden, unless permitted by WSO2 expressly. +# You may not alter or remove any copyright or other notice from copies of this content. +# +# -------------------------------------------------------------------------------------- + +resource "azurerm_monitor_alert_processing_rule_suppression" "monitor_alert_processing_rule_suppression" { + name = join("-", ["apr", var.monitor_alert_processing_rule_suppression_name]) + resource_group_name = var.resource_group_name + description = var.description + scopes = var.scopes + enabled = var.enabled + tags = var.tags + + condition { + monitor_condition { + operator = var.operator + values = var.values + } + } +} diff --git a/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/variables.tf b/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/variables.tf new file mode 100644 index 00000000..40d928f0 --- /dev/null +++ b/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/variables.tf @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved. +# +# This software is the property of WSO2 LLC. and its suppliers, if any. +# Dissemination of any information or reproduction of any material contained +# herein in any form is strictly forbidden, unless permitted by WSO2 expressly. +# You may not alter or remove any copyright or other notice from copies of this content. +# +# -------------------------------------------------------------------------------------- + +variable "resource_group_name" { + description = "Name of the Resource Group" + type = string +} + +variable "monitor_alert_processing_rule_suppression_name" { + description = "Name of the Monitor Alert Processing Rule Suppression" + type = string +} + +variable "tags" { + description = "Tags for the Resource" + type = map(string) +} + +variable "scopes" { + description = "The scopes to apply the suppression to" + type = list(string) +} + +variable "description" { + description = "Description of the Monitor Alert Processing Rule Suppression" + type = string +} + +variable "enabled" { + description = "Is the Monitor Alert Processing Rule Suppression Enabled?" + type = bool + default = true +} + +variable "operator" { + description = "Operator for the Monitor Alert Processing Rule Suppression" + type = string + default = "Equals" +} + +variable "values" { + description = "Values for the Monitor Alert Processing Rule Suppression" + type = list(string) + default = ["Resolved"] +} diff --git a/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/versions.tf b/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/versions.tf new file mode 100644 index 00000000..52ef43af --- /dev/null +++ b/modules/azurerm/Monitor-Alert-Processing-Rule-Suppression-Resolved/versions.tf @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). All Rights Reserved. +# +# This software is the property of WSO2 LLC. and its suppliers, if any. +# Dissemination of any information or reproduction of any material contained +# herein in any form is strictly forbidden, unless permitted by WSO2 expressly. +# You may not alter or remove any copyright or other notice from copies of this content. +# +# -------------------------------------------------------------------------------------- + +terraform { + required_version = ">= 0.13" + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = ">= 3.52.0" + } + } +}