-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
112 lines (94 loc) · 4 KB
/
main.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
module "short_label" {
source = "applike/label/aws"
version = "1.1.0"
application = ""
context = module.this.context
}
resource "aws_cloudwatch_metric_alarm" "average-resource-cpu" {
count = module.this.enabled ? 1 : 0
alarm_name = "${module.this.family}-${module.this.application}-average-cpu-high"
namespace = "ECS/ContainerInsights"
metric_name = "CpuUtilized"
statistic = "Average"
treat_missing_data = var.treat_missing_data
comparison_operator = "GreaterThanThreshold"
threshold = var.average_resource_cpu_threshold
period = var.average_resource_period
evaluation_periods = var.average_resource_evaluation_periods
datapoints_to_alarm = var.average_resource_datapoints_to_alarm
dimensions = {
ClusterName = module.short_label.id
TaskDefinitionFamily = module.this.id
}
alarm_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
ok_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
tags = module.this.tags
}
resource "aws_cloudwatch_metric_alarm" "average-resource-memory" {
count = module.this.enabled ? 1 : 0
alarm_name = "${module.this.family}-${module.this.application}-average-memory-high"
namespace = "ECS/ContainerInsights"
metric_name = "MemoryUtilized"
statistic = "Average"
treat_missing_data = var.treat_missing_data
comparison_operator = "GreaterThanThreshold"
threshold = var.average_resource_memory_threshold
period = var.average_resource_period
evaluation_periods = var.average_resource_evaluation_periods
datapoints_to_alarm = var.average_resource_datapoints_to_alarm
dimensions = {
ClusterName = module.short_label.id
TaskDefinitionFamily = module.this.id
}
alarm_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
ok_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
tags = module.this.tags
}
resource "aws_cloudwatch_metric_alarm" "maximum-resource-cpu" {
count = module.this.enabled ? 1 : 0
alarm_name = "${module.this.family}-${module.this.application}-maximum-cpu-high"
namespace = "AWS/ECS"
metric_name = "CPUUtilization"
statistic = "Maximum"
treat_missing_data = var.treat_missing_data
comparison_operator = "GreaterThanThreshold"
threshold = var.maximum_resource_cpu_threshold
period = var.maximum_resource_period
evaluation_periods = var.maximum_resource_evaluation_periods
datapoints_to_alarm = var.maximum_resource_datapoints_to_alarm
dimensions = {
ClusterName = module.short_label.id
ServiceName = module.this.application
}
alarm_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
ok_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
tags = module.this.tags
}
resource "aws_cloudwatch_metric_alarm" "maximum-resource-memory" {
count = module.this.enabled ? 1 : 0
alarm_name = "${module.this.family}-${module.this.application}-maximum-memory-high"
namespace = "AWS/ECS"
metric_name = "MemoryUtilization"
statistic = "Maximum"
treat_missing_data = var.treat_missing_data
comparison_operator = "GreaterThanThreshold"
threshold = var.maximum_resource_memory_threshold
period = var.maximum_resource_period
evaluation_periods = var.maximum_resource_evaluation_periods
datapoints_to_alarm = var.maximum_resource_datapoints_to_alarm
dimensions = {
ClusterName = module.short_label.id
ServiceName = module.this.application
}
alarm_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
ok_actions = [
"arn:aws:sns:eu-central-1:164105964448:${module.short_label.id}-info"]
tags = module.this.tags
}