File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Don't forget to remove desired_capacity on asg
2
+ resource "aws_autoscaling_policy" "heavy-out" {
3
+ name = " heavy-out-asg-policy"
4
+ scaling_adjustment = 1
5
+ adjustment_type = " ChangeInCapacity"
6
+ cooldown = 10
7
+ autoscaling_group_name = " ${ aws_autoscaling_group . heavy . name } "
8
+ }
9
+
10
+ resource "aws_autoscaling_policy" "heavy-in" {
11
+ name = " heavy-in-asg-policy"
12
+ scaling_adjustment = - 1
13
+ adjustment_type = " ChangeInCapacity"
14
+ cooldown = 10
15
+ autoscaling_group_name = " ${ aws_autoscaling_group . heavy . name } "
16
+ }
17
+
18
+ resource "aws_cloudwatch_metric_alarm" "heavy_asg_cpu_usage_is_very_high" {
19
+ alarm_name = " heavy-asg-cpu-usage-is-very-high"
20
+ comparison_operator = " GreaterThanOrEqualToThreshold"
21
+ evaluation_periods = 1
22
+ metric_name = " CPUUtilization"
23
+ namespace = " AWS/EC2"
24
+ period = 60
25
+ statistic = " Average"
26
+ threshold = 80
27
+ dimensions {
28
+ AutoScalingGroupName = " ${ aws_autoscaling_group . heavy . name } "
29
+ }
30
+ alarm_description = " This metric monitors EC2 CPU utilization"
31
+ alarm_actions = [" ${ aws_autoscaling_policy . heavy-out . arn } " ]
32
+ }
33
+
34
+ resource "aws_cloudwatch_metric_alarm" "heavy_asg_cpu_usage_is_very_low" {
35
+ alarm_name = " heavy-asg-cpu-usage-is-very-low"
36
+ comparison_operator = " LessThanOrEqualToThreshold"
37
+ evaluation_periods = 1
38
+ metric_name = " CPUUtilization"
39
+ namespace = " AWS/EC2"
40
+ period = 60
41
+ statistic = " Average"
42
+ threshold = 40
43
+ dimensions {
44
+ AutoScalingGroupName = " ${ aws_autoscaling_group . heavy . name } "
45
+ }
46
+ alarm_description = " This metric monitors EC2 CPU utilization"
47
+ alarm_actions = [" ${ aws_autoscaling_policy . heavy-in . arn } " ]
48
+ }
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ resource "aws_elb" "heavy" {
147
147
health_check {
148
148
healthy_threshold = 2
149
149
unhealthy_threshold = 2
150
- interval = 15
150
+ interval = 7
151
151
timeout = 5
152
152
target = " HTTP:80/"
153
153
}
You can’t perform that action at this time.
0 commit comments