forked from cloudposse/terraform-aws-ec2-instance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud_watch_alarm.tf
30 lines (25 loc) · 965 Bytes
/
cloud_watch_alarm.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
# Restart dead or hung instance
resource "null_resource" "check_alarm_action" {
count = "${local.instance_count}"
triggers = {
action = "arn:aws:swf:${local.region}:${data.aws_caller_identity.default.account_id}:${var.default_alarm_action}"
}
}
resource "aws_cloudwatch_metric_alarm" "default" {
count = "${local.instance_count}"
alarm_name = "${module.label.id}"
comparison_operator = "${var.comparison_operator}"
evaluation_periods = "${var.evaluation_periods}"
metric_name = "${var.metric_name}"
namespace = "${var.metric_namespace}"
period = "${var.applying_period}"
statistic = "${var.statistic_level}"
threshold = "${var.metric_threshold}"
depends_on = ["null_resource.check_alarm_action"]
dimensions {
InstanceId = "${aws_instance.default.id}"
}
alarm_actions = [
"${null_resource.check_alarm_action.triggers.action}",
]
}