-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathautoscaling-cpu.template
105 lines (105 loc) · 2.85 KB
/
autoscaling-cpu.template
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
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "EC2 AutoScaling Policies with CloudWatch alarms. Scales up and scales down.",
"Parameters": {
"AutoScalingGroup": {
"Description": "The EC2 AutoScalingGroup name we wish to attach these scaling policies to.",
"Type": "String"
},
"CPUAlarmHighThreshold": {
"Description": "Overall cluster CPU usage by percentage where we trigger a scale up action.",
"Type": "String",
"Default": "70"
},
"CPUAlarmLowThreshold": {
"Description": "Overall cluster CPU usage by percentage where we trigger a scale down action.",
"Type": "String",
"Default": "40"
},
"StacksVersion": {
"Description": "Version of the Nubis Stacks",
"Type": "String",
"Default": "v1.4.0-dev"
}
},
"Resources": {
"ScaleUpPolicy": {
"Type": "AWS::AutoScaling::ScalingPolicy",
"Properties": {
"AdjustmentType": "ChangeInCapacity",
"AutoScalingGroupName": {
"Ref": "AutoScalingGroup"
},
"Cooldown": "60",
"ScalingAdjustment": "1"
}
},
"ScaleDownPolicy": {
"Type": "AWS::AutoScaling::ScalingPolicy",
"Properties": {
"AdjustmentType": "ChangeInCapacity",
"AutoScalingGroupName": {
"Ref": "AutoScalingGroup"
},
"Cooldown": "60",
"ScalingAdjustment": "-1"
}
},
"CPUAlarmHigh": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"EvaluationPeriods": "2",
"Statistic": "Average",
"Threshold": {
"Ref": "CPUAlarmHighThreshold"
},
"AlarmDescription": "Alarm if cpu too high or metric disappears indicating instance is down",
"Period": "60",
"AlarmActions": [
{
"Ref": "ScaleUpPolicy"
}
],
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "AutoScalingGroupName",
"Value": {
"Ref": "AutoScalingGroup"
}
}
],
"ComparisonOperator": "GreaterThanThreshold",
"MetricName": "CPUUtilization"
}
},
"CPUAlarmLow": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"EvaluationPeriods": "2",
"Statistic": "Average",
"Threshold": {
"Ref": "CPUAlarmLowThreshold"
},
"AlarmDescription": "Alarm if cpu too low",
"Period": "60",
"AlarmActions": [
{
"Ref": "ScaleDownPolicy"
}
],
"Namespace": "AWS/EC2",
"Dimensions": [
{
"Name": "AutoScalingGroupName",
"Value": {
"Ref": "AutoScalingGroup"
}
}
],
"ComparisonOperator": "LessThanThreshold",
"MetricName": "CPUUtilization"
}
}
}
}