-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalerts.tf
28 lines (24 loc) · 883 Bytes
/
alerts.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
data "template_file" "ecs_task_stopped" {
template = file("${path.module}/alerts/ecs_task_stopped.json")
vars = {
cluster_arn = aws_ecs_cluster.cluster.arn
}
}
resource "aws_sns_topic" "events" {
name = local.name
tags = local.tags
}
// TODO: as soon as CWE Service / ServiceEvent also filter on
// "unable to place a task" messages in ServiceEvent instances
//
// see https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Service.html
resource "aws_cloudwatch_event_rule" "ecs_task_stopped" {
description = "${local.name} Essential container in task exited"
event_pattern = data.template_file.ecs_task_stopped.rendered
name = "${local.name}-task-stopped"
tags = local.tags
}
resource "aws_cloudwatch_event_target" "ecs_task_stopped" {
arn = aws_sns_topic.events.arn
rule = aws_cloudwatch_event_rule.ecs_task_stopped.name
}