-
Notifications
You must be signed in to change notification settings - Fork 6
/
cloudwatch-alarms.tf
41 lines (36 loc) · 1.51 KB
/
cloudwatch-alarms.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
29
30
31
32
33
34
35
36
37
38
39
40
41
resource "aws_cloudwatch_metric_alarm" "high_memory" {
count = length(var.alarm_sns_topics) > 0 ? 1 : 0
alarm_name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.cluster_name}-${var.name}-high-memory"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "3"
metric_name = "MemoryUtilization"
namespace = "AWS/ECS"
period = "300"
statistic = "Maximum"
threshold = "80"
alarm_description = "Cluster node memory above threshold"
alarm_actions = var.alarm_sns_topics
ok_actions = var.alarm_sns_topics
dimensions = {
ClusterName = var.cluster_name
ServiceName = aws_ecs_service.default.name
}
}
resource "aws_cloudwatch_metric_alarm" "high_cpu" {
count = length(var.alarm_sns_topics) > 0 ? 1 : 0
alarm_name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.cluster_name}-${var.name}-high-cpu"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "3"
metric_name = "CPUUtilization"
namespace = "AWS/ECS"
period = "300"
statistic = "Maximum"
threshold = "80"
alarm_description = "ECS service CPU utilization above threshold"
alarm_actions = var.alarm_sns_topics
ok_actions = var.alarm_sns_topics
dimensions = {
ClusterName = var.cluster_name
ServiceName = aws_ecs_service.default.name
}
}