From 4ab7b9dfd773450c2d10f5e9af6a29f7360b762c Mon Sep 17 00:00:00 2001 From: Chirag Pareek Date: Tue, 2 Jan 2024 12:09:28 +0000 Subject: [PATCH] DTSPO-15909 - migrated Application Insights --- application-insights.tf | 24 ++++++++++++------------ emailAlert.tf | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/application-insights.tf b/application-insights.tf index 37e68bb..dd1bc6c 100644 --- a/application-insights.tf +++ b/application-insights.tf @@ -1,16 +1,16 @@ -resource "azurerm_application_insights" "appinsights" { - name = join("-", [var.product, var.env]) - location = var.location +module "application_insights" { + source = "git@github.com:hmcts/terraform-module-application-insights?ref=main" + + env = var.env + product = var.product + name = var.product + resource_group_name = azurerm_resource_group.rg.name - application_type = var.application_type - tags = local.tags - lifecycle { - ignore_changes = [ - # Ignore changes to appinsights as otherwise upgrading to the Azure provider 2.x - # destroys and re-creates this appinsights instance - application_type, - ] - } + common_tags = local.tags } +moved { + from = azurerm_application_insights.appinsights + to = module.application_insights.azurerm_application_insights.this +} diff --git a/emailAlert.tf b/emailAlert.tf index 8b9f9e7..69784f8 100644 --- a/emailAlert.tf +++ b/emailAlert.tf @@ -2,12 +2,12 @@ module "feepay-fail-alert" { source = "git@github.com:hmcts/cnp-module-metric-alert" - location = azurerm_application_insights.appinsights.location - app_insights_name = azurerm_application_insights.appinsights.name + location = var.location + app_insights_name = "${var.product}-${var.env}" - alert_name = "feepay-fail-alert" - alert_desc = "Triggers when an feepay exception is received." - app_insights_query = "requests | where toint(resultCode) >= 500 | sort by timestamp desc" + alert_name = "feepay-fail-alert" + alert_desc = "Triggers when an feepay exception is received." + app_insights_query = "requests | where toint(resultCode) >= 500 | sort by timestamp desc" frequency_in_minutes = "15" time_window_in_minutes = "15" @@ -30,18 +30,18 @@ module "feepay-fail-action-group" { action_group_name = "feepay Fail Alert - ${var.env}" short_name = "feepay_alert" email_receiver_name = "feepay Alerts" - email_receiver_address = "${data.azurerm_key_vault_secret.email-alert-recipient.value}" + email_receiver_address = data.azurerm_key_vault_secret.email-alert-recipient.value } data "azurerm_key_vault_secret" "email-alert-recipient" { name = "email-alert-recipient" key_vault_id = data.azurerm_key_vault.ccpay_key_vault.id - } - - output "email-alert-recipient" { - value = data.azurerm_key_vault_secret.email-alert-recipient - sensitive=true +} + +output "email-alert-recipient" { + value = data.azurerm_key_vault_secret.email-alert-recipient + sensitive = true }