diff --git a/terraform/environment/alerts.tf b/terraform/environment/alerts.tf index 6dd2ef3b..6f7b71f3 100644 --- a/terraform/environment/alerts.tf +++ b/terraform/environment/alerts.tf @@ -2,6 +2,10 @@ data "aws_sns_topic" "rest_api" { name = "rest-api" } +data "aws_sns_topic" "lpa_data_api" { + name = "CloudWatch-LPA-Data-to-PagerDuty-${local.account.account_mapping}-eu-west-1" +} + resource "aws_cloudwatch_metric_alarm" "rest_api_5xx_errors" { actions_enabled = true alarm_actions = [data.aws_sns_topic.rest_api.arn] @@ -47,8 +51,9 @@ resource "aws_cloudwatch_metric_alarm" "rest_api_high_count" { } resource "aws_cloudwatch_metric_alarm" "rest_api_slow_response" { + count = local.account.is_production ? 1 : 0 actions_enabled = true - alarm_actions = [data.aws_sns_topic.rest_api.arn] + alarm_actions = [data.aws_sns_topic.lpa_data_api.arn] alarm_description = "Average response time over a minute for LPA Data Rest API in ${terraform.workspace}" alarm_name = "lpa-${local.environment}-rest-api-slow-response" comparison_operator = "GreaterThanThreshold" @@ -60,7 +65,7 @@ resource "aws_cloudwatch_metric_alarm" "rest_api_slow_response" { insufficient_data_actions = [] metric_name = "Latency" namespace = "AWS/ApiGateway" - ok_actions = [data.aws_sns_topic.rest_api.arn] + ok_actions = [data.aws_sns_topic.lpa_data_api.arn] period = 60 statistic = "Average" tags = {}