Skip to content

Commit 318f177

Browse files
authored
Merge branch 'main' into PRMP-1510
2 parents e62b9ae + f127786 commit 318f177

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

infrastructure/sqs-stitching.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,52 @@ module "sqs-stitching-queue" {
88
max_visibility = 1200
99
enable_dlq = true
1010
}
11+
12+
resource "aws_cloudwatch_metric_alarm" "stitching_dlq_new_messages" {
13+
alarm_name = "${terraform.workspace}_stitching_dlq_messages"
14+
comparison_operator = "GreaterThanThreshold"
15+
evaluation_periods = 1
16+
metric_name = "ApproximateNumberOfMessagesVisible"
17+
namespace = "AWS/SQS"
18+
period = 60
19+
statistic = "Sum"
20+
threshold = 0
21+
alarm_description = "Alarm when there are new messages in the stitching dlq"
22+
alarm_actions = [module.stitching-dlq-alarm-topic.arn]
23+
24+
dimensions = {
25+
QueueName = module.sqs-stitching-queue.dlq_name
26+
}
27+
}
28+
29+
module "stitching-dlq-alarm-topic" {
30+
source = "./modules/sns"
31+
sns_encryption_key_id = module.sns_encryption_key.id
32+
current_account_id = data.aws_caller_identity.current.account_id
33+
topic_name = "stitching-dlq-topic"
34+
topic_protocol = "email"
35+
is_topic_endpoint_list = true
36+
topic_endpoint_list = nonsensitive(split(",", data.aws_ssm_parameter.cloud_security_notification_email_list.value))
37+
delivery_policy = jsonencode({
38+
"Version" : "2012-10-17",
39+
"Statement" : [
40+
{
41+
"Effect" : "Allow",
42+
"Principal" : {
43+
"Service" : "cloudwatch.amazonaws.com"
44+
},
45+
"Action" : [
46+
"SNS:Publish",
47+
],
48+
"Condition" : {
49+
"ArnLike" : {
50+
"aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*"
51+
}
52+
}
53+
"Resource" : "*"
54+
}
55+
]
56+
})
57+
58+
depends_on = [module.sqs-stitching-queue]
59+
}

0 commit comments

Comments
 (0)