-
Notifications
You must be signed in to change notification settings - Fork 31
/
cloutwatch-alarms-ecs.tf
57 lines (50 loc) · 1.97 KB
/
cloutwatch-alarms-ecs.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
resource "aws_cloudwatch_metric_alarm" "ecs_high_memory" {
count = !var.fargate_only && length(var.alarm_sns_topics) > 0 && var.alarm_ecs_high_cpu_threshold != 0 ? 1 : 0
alarm_name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-high-memory"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "3"
metric_name = "MemoryUtilization"
namespace = "AWS/ECS"
period = "120"
statistic = "Average"
threshold = var.alarm_ecs_high_memory_threshold
alarm_description = "Cluster memory above threshold"
alarm_actions = var.alarm_sns_topics
ok_actions = var.alarm_sns_topics
insufficient_data_actions = []
treat_missing_data = "ignore"
dimensions = {
ClusterName = aws_ecs_cluster.ecs.name
}
tags = merge(
var.tags,
{
"Terraform" = true
},
)
}
resource "aws_cloudwatch_metric_alarm" "ecs_high_cpu" {
count = !var.fargate_only && length(var.alarm_sns_topics) > 0 && var.alarm_ecs_high_cpu_threshold != 0 ? 1 : 0
alarm_name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-high-cpu"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "3"
metric_name = "CPUUtilization"
namespace = "AWS/ECS"
period = "120"
statistic = "Average"
threshold = var.alarm_ecs_high_cpu_threshold
alarm_description = "Cluster CPU above threshold"
alarm_actions = var.alarm_sns_topics
ok_actions = var.alarm_sns_topics
insufficient_data_actions = []
treat_missing_data = "ignore"
dimensions = {
ClusterName = aws_ecs_cluster.ecs.name
}
tags = merge(
var.tags,
{
"Terraform" = true
},
)
}