-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarms.tf
63 lines (56 loc) · 2.03 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
resource "aws_cloudwatch_metric_alarm" "demo_resource_count" {
alarm_name = "demo-resource-count"
namespace = "AWS/Usage"
metric_name = "ResourceCount"
evaluation_periods = "1"
period = "60"
statistic = "Minimum"
comparison_operator = "LessThanThreshold"
threshold = "1"
alarm_actions = [aws_sns_topic.alarm_notifier_topic.arn]
ok_actions = [aws_sns_topic.alarm_notifier_topic.arn]
dimensions = {
Service = "EC2"
Type = "Resource"
Resource = "vCPU"
Class = "Standard/OnDemand"
}
}
resource "aws_cloudwatch_metric_alarm" "demo_status_check" {
alarm_name = "demo-status-check"
namespace = "AWS/EC2"
metric_name = "StatusCheckFailed"
evaluation_periods = "1"
period = "60"
statistic = "Maximum"
comparison_operator = "GreaterThanOrEqualToThreshold"
threshold = "1"
alarm_actions = [aws_sns_topic.alarm_notifier_topic.arn]
ok_actions = [aws_sns_topic.alarm_notifier_topic.arn]
depends_on = [
aws_instance.demo_server,
aws_sns_topic.alarm_notifier_topic
]
dimensions = {
InstanceId = aws_instance.demo_server.id
}
}
resource "aws_cloudwatch_metric_alarm" "demo_cpu_usage" {
alarm_name = "demo-cpu-utilization"
namespace = "AWS/EC2"
metric_name = "CPUUtilization"
evaluation_periods = "5"
period = "60"
statistic = "Average"
comparison_operator = "GreaterThanOrEqualToThreshold"
threshold = "80"
alarm_actions = [aws_sns_topic.alarm_notifier_topic.arn]
ok_actions = [aws_sns_topic.alarm_notifier_topic.arn]
depends_on = [
aws_instance.demo_server,
aws_sns_topic.alarm_notifier_topic
]
dimensions = {
InstanceId = aws_instance.demo_server.id
}
}