-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.tf
93 lines (84 loc) · 3.58 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
resource "aws_cloudwatch_metric_alarm" "httpcode_target_5xx_count" {
alarm_name = "${var.prefix}alb-tg-${var.target_group_id}-high5XXCount"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = var.evaluation_period
metric_name = "HTTPCode_Target_5XX_Count"
namespace = "AWS/ApplicationELB"
period = var.statistic_period
statistic = "Sum"
threshold = "0"
alarm_description = "Average API 5XX target group error code count is too high"
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
"TargetGroup" = var.target_group_id
"LoadBalancer" = var.load_balancer_id
}
}
resource "aws_cloudwatch_metric_alarm" "httpcode_lb_5xx_count" {
alarm_name = "${var.prefix}alb-${var.load_balancer_id}-high5XXCount"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = var.evaluation_period
metric_name = "HTTPCode_ELB_5XX_Count"
namespace = "AWS/ApplicationELB"
period = var.statistic_period
statistic = "Sum"
threshold = "0"
alarm_description = "Average API 5XX load balancer error code count is too high"
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
"LoadBalancer" = var.load_balancer_id
}
}
resource "aws_cloudwatch_metric_alarm" "target_response_time_average" {
alarm_name = "${var.prefix}alb-tg-${var.target_group_id}-highResponseTime"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = var.evaluation_period
metric_name = "TargetResponseTime"
namespace = "AWS/ApplicationELB"
period = var.statistic_period
statistic = "Average"
threshold = var.response_time_threshold
alarm_description = format("Average API response time is greater than %s", var.response_time_threshold)
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
"TargetGroup" = var.target_group_id
"LoadBalancer" = var.load_balancer_id
}
}
resource "aws_cloudwatch_metric_alarm" "unhealthy_hosts" {
alarm_name = "${var.prefix}alb-tg-${var.target_group_id}-unhealthy-hosts"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = var.evaluation_period
metric_name = "UnHealthyHostCount"
namespace = "AWS/ApplicationELB"
period = var.statistic_period
statistic = "Minimum"
threshold = var.unhealthy_hosts_threshold
alarm_description = format("Unhealthy host count is greater than %s", var.unhealthy_hosts_threshold)
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
"TargetGroup" = var.target_group_id
"LoadBalancer" = var.load_balancer_id
}
}
resource "aws_cloudwatch_metric_alarm" "healthy_hosts" {
alarm_name = "${var.prefix}alb-tg-${var.target_group_id}-healthy-hosts"
comparison_operator = "LessThanOrEqualToThreshold"
evaluation_periods = var.evaluation_period
metric_name = "HealthyHostCount"
namespace = "AWS/ApplicationELB"
period = var.statistic_period
statistic = "Minimum"
threshold = var.healthy_hosts_threshold
alarm_description = format("Healthy host count is less than or equal to %s", var.healthy_hosts_threshold)
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
"TargetGroup" = var.target_group_id
"LoadBalancer" = var.load_balancer_id
}
}