Skip to content

Commit

Permalink
UML-3396: fix data block and sns topic (#159)
Browse files Browse the repository at this point in the history
* UML-3396: fix data block and sns topic

* use account instead of environment

* fix fmt

* remove resource instance key

* try account_mapping
  • Loading branch information
jay-whitwell authored Aug 12, 2024
1 parent 0f2b8b9 commit a8eb7a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions terraform/environment/alerts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand All @@ -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 = {}
Expand Down

0 comments on commit a8eb7a6

Please sign in to comment.