-
Notifications
You must be signed in to change notification settings - Fork 16
/
autoscaling.aws.txt
394 lines (353 loc) · 26 KB
/
autoscaling.aws.txt
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
AUTOSCALING
AUTOSCALING ==> #Version from 2014/07/30
AUTOSCALINGGROUP ==> #Launch|Terminate (ScalingActivity) instances in order to maintain DesiredCapacity of them.
#DesiredCapacity must be withing Min|Max.
#Based on ScalingPlan:
# - manual: by manually changing DesiredCapacity|Min|Max
# - dynamic: ScalingPolicy:
# - specifies how many instances to launch|terminate with ScalingAdjustment NUM, which can be
# - absolute value ("ExactCapacity")
# - relative value ("ChangeInCapacity")
# - percent-relative value ("PercentChangeInCapacity").
# - Round-off towards 1 for [-1;+1] and towards 0 otherwise
# - Can use MinAdjustmentStep NUM to specify a step.
# - should create one for scaling down, one for scaling up
# - ScalingPolicy are triggered either:
# - by CloudWatch alarms, with PutMetricAlarm() AlarmActions SCALING_POLICY_ARN, i.e.
# "arn:aws:autoscaling:REGION:ACCOUNT_ID:scalingPolicy:SCALING_POLICY_ID:
# autoScalingGroupName/SCALING_GROUP_NAME/policyName/SCALING_POLICY_NAME"
# - manually
# - scheduled: ScheduledUpdateGroupAction changing DesiredCapacity|Min|Max at specific times:
# - at regular interval (Recurrence STR, using cron syntax)
# - during specific period: StartTime and/or EndTime (max one month in future)
# - might have up to 2 mins delay
#Wait for cooldown time after an instance is done being launched, when another one just
#terminated (def: 5 mins):
# - reason: other instances are going to experience high metrics while new instance just
# launched, but it is normal
# - during cooldown, no extra ScalingActivity is done
# - ScalingPolicy can override cooldown
#Termination:
# - always ignore the no Termination attribute of EC2
# - chooses within the AvailabilityZone with the most instances (or randomly if equal)
# - if ELB + ConnectionDraining, waits for connection draining to end
# - TerminationPolicy: which instance to terminate (inside the chosen AvailabilityZone), among
# (can be several by order of preference):
# - Oldest|NewestInstance: instance launch time
# - Oldest|NewestLaunchConfiguration: LaunchConfiguration creation time
# - ClosestToNextInstanceHour: to minimize billing cost
# - Default: like [ "OldestLaunchConfiguration", "ClosestToNextInstanceHour" ]
#VPC:
# - distribute evenly in AvailabilityZones (specified in AutoScalingGroup), but not in ones that
# are unhealthy
# - AvailabilityZones balancing: Launch|Terminate to rebalance between AvailabilityZones if not
# balanced
# - To launch in specific subnets, must specify it in AutoScalingGroup
#Launch:
# - LaunchConfiguration: parameters of RunInstances()
# - Auto-associate new instances (not existing ones) with LoadBalancers specified in
# AutoScalingGroup
HEALTH CHECKS ==> #Use HealthCheckType, either:
# - "EC2": instance system status checks or EC2 instance not running
# - "ELB": health checks (implies "EC2" too)
# - Can have custom health checks by manually triggering with SetInstanceHealth()
#If unhealthy, terminates it then starts a new instance.
#Waits for HealthCheckGracePeriod (def: 5 mins) after instance finished launching before checking
#health (except check that EC2 instance is running)
MANUAL MAINTAINANCE ==> #Can use EnterStandby():
# - temporarily detach the instance (should use option to decrement DesiredCapacity if plan to
# puck it right back up)
# - as opposed to real detachment, still seems associated, and can be cancelled quickly with
# ExitStandby()
#Can suspend scaling processes with Suspend|ResumeProcesses():
# - "Launch|Terminate" instance (from any way)
# - "HealthCheck"
# - "ReplaceUnhealthy"
# - "AZRebalance": AvailabilityZones balancing
# - "AlarmNotification": CloudWatch alarms actions
# - "ScheduledActions"
# - "AddToLoadBalancer": auto-associating with LoadBalancers
LIFECYCLE ==> #Instance LifecycleState can be:
# - "Pending": about to be launched (because of scaling up, not because of new AutoScalingGroup)
# - "InService": normal
# - "[Entering]Standby"
# - "Terminating|Terminated" or "Detaching|Detached"
# - "Quarantined": not sure when this happens
#Hooks put "Pending|Terminating" into "Pending|Terminating:Wait":
# - will not be detached|attached from AutoScalingGroup until either:
# - timeout HeartbeatTimeout (def: 1 hour, max: 2 days)
# - Can add new delay to timeout (equals to HeartbeatTimeout) with
# RecordLifecycleActionHeartbeat()
# - manual trigger with CompleteLifecycleAction() (can complete or abandon)
# - then becomes "Pending|Terminating:Proceed"
# - can be notified with SQS or SNS. Need to specify a ROLE for the notification sending.
# - use LifecycleTransition "autoscaling:EC2_INSTANCE_LAUNCHING|TERMINATING"
# - example use:
# - "Pending:Wait":
# - configuration that cannot be done in init script
# - "caching" EC2 instances (running but not attached yet)
# - "Termating:Wait":
# - inspect reasons of termination
SNS NOTIFICATIONS ==> #Can be used on instances launch|terminate.
CLOUDWATCH ==> #Only if:
# - instances of the AutoScalingGroup have EC2 detailed monitoring on
# - and enabled with EnableMetricsCollection()
#METRIC:
# - GroupMinSize|MaxSize|DesiredCapacity NUM
# - GroupPending|InService|Standby|TerminatingInstances NUM
# - GroupTotalInstances NUM
#Dimension: AutoScalingGroupName
ARN ==> #None to be used with IAM (can still use IAM policy)
LIMITS ==> # - 20 AutoScalingGroup
# - 100 LaunchConfiguration
# - 125 ScheduledAction/month
DescribeAccountLimits() #Response body:
# - MaxNumberOfAutoScalingGroups NUM
# - MaxNumberOfLaunchConfigurations NUM
PRICING ==> #Free
/=+===============================+=\
/ : : \
)==: API :==(
\ :_______________________________: /
\=+===============================+=/
API ==> # - ARR.member.NUM (REST API) -> ARR (SDKs)
PAGINATION ==> # - Request variables: MaxRecords NUM (def: 10000 log events or 1MB), NextToken STR
# - Response body: NextToken STR
/=+===============================+=\
/ : : \
)==: METHODS :==(
\ :_______________________________: /
\=+===============================+=/
AttachInstances() #Request variables:
# - AutoScalingGroupName STR
# - InstanceIds STR_ARR
DetachInstances() #Request variables:
# - AutoScalingGroupName STR
# - InstanceIds STR_ARR
# - ShouldDecrementDesiredCapacity BOOL (def: false)
#Response body: Activities ACTIVITY_ARR:
# - ActivityId STR
# - AutoScalingGroupName STR
# - Cause STR
# - Description STR
# - Details STR
# - StartTime|EndTime DATE
# - Progress NUM
# - StatusCode "WaitingForSpotInstanceRequestId|WaitingForSpotInstanceId|WaitingForInstanceId|
# PreInService|InProgress|WaitingForELBConnectionDraining|MidLifecycleAction|Successful|
# Failed|Cancelled"
# - StatusMessage STR
Enter|ExitStandby() #Request variables:
# - AutoScalingGroupName STR
# - InstanceIds STR_ARR
# - ShouldDecrementDesiredCapacity BOOL (only for Enter) (def: false)
#Response body: Activities ACTIVITY_ARR
TerminateInstanceInAuto #Request variables:
ScalingGroup() # - InstanceId STR
# - ShouldDecrementDesiredCapacity BOOL (def: false)
#Response body: Activity ACTIVITY
Suspend|ResumeProcesses() #Request variables:
# - AutoScalingGroupName STR
# - ScalingProcesses STR_ARR, among "" (all), "Launch", "Terminate", "HealthCheck",
# "ReplaceUnhealthy", "AZRebalance", "AlarmNotification", "ScheduledActions",
# "AddToLoadBalancer"
CreateAutoScalingGroup() #Request variables AUTO_SCALING_GROUP:
# - AutoScalingGroupName STR
# - AvailabilityZones STR_ARR: to launch instances
# - HealthCheckType "EC2|ELB"
# - HealthCheckGracePeriod NUM
# - DefaultCooldown NUM
# - LaunchConfigurationName STR or InstanceId STR (use it as LaunchConfiguration)
# - LoadBalancerNames STR_ARR
# - Min|MaxSize NUM
# - DesiredCapacity NUM
# - PlacementGroup STR
# - Tags TAG_ARR
# - TerminationPolicies STR_ARR
# - VPCZoneIdentifier "SUBNET_ID,..."
UpdateAutoScalingGroup() #Request variables AUTO_SCALING_GROUP, without InstanceId, LoadBalancerNames, Tags
DeleteAutoScalingGroup() #Request variables:
# - AutoScalingGroupName STR
# - ForceDelete BOOL
DescribeAutoScalingInstances()#Request variables: InstanceIds STR_ARR
#Response body: AutoScalingInstances AUTO_SCALING_INSTANCE:
# - AutoScalingGroupName STR
# - AvailabilityZone STR
# - HealthStatus STR
# - LaunchConfigurationName STR or InstanceId STR
# - LifecycleState "Pending|Pending:Wait|Pending:Proceed|Quarantined|InService|Terminating|
# Terminating:Wait|Terminating:Proceed|Terminated|Detaching|Detached|EnteringStandby|Standby"
#Paginates.
DescribeAutoScalingGroups() #Request variables:
# - AutoScalingGroupNames STR_ARR
#Response body: AutoScalingGroups OBJ_ARR:
# - Same members as AUTO_SCALING_GROUP, except InstanceId
# - Instances AUTO_SCALING_INSTANCE_ARR, without AutoScalingGroupName STR
# - AutoScalingGroupARN STR
# - CreatedTime DATE
# - EnabledMetrics OBJ_ARR:
# - Granularity STR
# - Metric "1minute"
# - Status STR
# - SuspendedProcesses OBJ_ARR:
# - ProcessName STR
# - SuspensionReason STR
#Paginates.
SetDesiredCapacity() #Request variables:
# - AutoScalingGroupName STR
# - DesiredCapacity NUM
# - HonorCooldown BOOL (def: false): waits if there is an ongoing cooldown
CreateLaunchConfiguration() #Request variables LAUNCH_CONF:
# - same as EC2 RunInstances() request parameters but:
# - no Min|MaxCount, AdditionalInfo, ClientToken, DisableApiTermination,
# InstanceInitiatedShutdownBehavior, NetworkInterfaces, PrivateIpAddress, SubnetId
# - IamInstanceProfile STR -> IamInstanceProfile: Arn STR, Name STR
# - Monitoring -> InstanceMonitoring { Enabled BOOL }
# - Placement OBJ -> PlacementTenancy "default|dedicated"
# - SecurityGroups -> SecurityGroupIds
# - InstanceId STR: copy instance params directly (must specify DeviceBlockMappings manually),
# but can override some by specifying them
# - AssociatePublicIpAddress BOOL
# - LaunchConfigurationName STR
# - SpotPrice STR
DeleteLaunchConfiguration() #Request variables: LaunchConfigurationName STR
DescribeLaunchConfigurations()#Request variables: LaunchConfigurationNames STR_ARR
#Response body: LaunchConfigurations LAUNCH_CONF_ARR
#Paginates
PutScalingPolicy() #Request variables SCALING_POLICY:
# - AutoScalingGroupName STR
# - PolicyName STR
# - ScalingAdjustment NUM
# - AdjustmentType "ChangeInCapacity|ExactCapacity|PercentChangeInCapacity"
# - MinAdjustmentStep NUM
# - Cooldown NUM
#Response body: PolicyARN SCALING_POLICY_ARN
ExecutePolicy() #Request variables:
# - AutoScalingGroupName STR
# - HonorCooldown BOOL
# - PolicyName STR
DeletePolicy() #Request variables:
# - AutoScalingGroupName STR
# - PolicyName STR
DescribePolicies() #Request variables:
# - AutoScalingGroupName STR
# - PolicyNames STR_ARR
#Response body: ScalingPolicies OBJ_ARR:
# - Same members as SCALING_POLICY
# - Alarms OBJ_ARR: AlarmARN, AlarmName STR
# - PolicyARN SCALING_POLICY_ARN
#Paginates
PutScheduledUpdateGroupAction #Request variables SCHEDULED_ACTION:
# - AutoScalingGroupName STR
# - DesiredCapacity NUM
# - MinSize|MaxSize NUM
# - StartTime|EndTime DATE
# - Recurrence STR (Cron syntax)
# - ScheduledActionName STR
DeleteScheduledAction() #Request variables:
# - AutoScalingGroupName STR
# - ScheduledActionName STR
DescribeScheduledActions() #Request variables:
# - AutoScalingGroupName STR
# - ScheduledActionName STR
# - StartTime|EndTime DATE
#Response body: ScheduledUpdateGroupActions SCHEDULED_ACTION_ARR
#Paginates
DescribeScalingActivities() #Request parameters:
# - ActivityIds STR_ARR
# - AutoScalingGroupName STR
#Response body: Activities ACTIVITY_ARR
#Paginates
SetInstanceHealth() #Request variables:
# - HealthStatus "[Un]Healthy"
# - InstanceId STR
# - ShouldRespectGracePeriod BOOL (def: true)
PutLifecycleHook() #Request variables LIFECYCLE_HOOK:
# - AutoScalingGroupName STR
# - LifecycleHookName STR
# - LifecycleTransition "autoscaling:EC2_INSTANCE_LAUNCHING|TERMINATING"
# - HeartbeatTimeout NUM (in sec)
# - DefaultResult "CONTINUE|ABANDON" (def: "ABANDON")
# - NotificationTargetARN SNS|SQS_ARN
# - NotificationMetadata STR
# - RoleARN
DeleteLifecycleHook() #Request variables:
# - AutoScalingGroupName STR
# - LifecycleHookName STR
DescribeLifecycleHooks() #Request variables:
# - AutoScalingGroupName STR
# - LifecycleHookNames STR_ARR
#Response body: LifecycleHooks LIFECYCLE_HOOK_ARR, with also:
# - GlobalTimeout NUM (max timeout, 2 hours)
RecordLifecycleActionHeartbeat#Request variables LIFECYCLE_ACTION:
# - AutoScalingGroupName STR
# - LifecycleHookName STR
# - LifecycleActionToken STR (36 chars): required security token sent with the notification
# Sent with the SNS notification.
CompleteLifecycleAction() #Request variables:
# - Same members as LIFECYCLE_ACTION
# - LifecycleActionResult "CONTINUE|ABANDON"
EnableMetricsCollection() #Request variables:
# - AutoScalingGroupName STR
# - Granularity "1Minute"
# - Metrics METRIC_STR_ARR, among [ "GroupMinSize", "GroupMaxSize", "GroupDesiredCapacity",
# "GroupInServiceInstances", "GroupPendingInstances", "GroupStandbyInstances",
# "GroupTerminatingInstances", "GroupTotalInstances", ]
DisableMetricsCollection() #Request variables:
# - AutoScalingGroupName STR
# - Metrics METRIC_STR_ARR
PutNotificationConfiguration()#Request variables:
# - AutoScalingGroupName STR
# - NotificationTypes STR_ARR,
# among "autoscaling:TEST_NOTIFICATION|EC2_INSTANCE_LAUNCH|TERMINATE[_ERROR]"
# - TopicARN
DeleteNotification #Request variables:
Configurations() # - AutoScalingGroupName STR
# - TopicARN
DescribeNotification #Request variables: AutoScalingGroupNames STR_ARR
Configuration() #Paginates
CreateOrUpdate|DeleteTags() #Request variables: Tags TAG_ARR:
# - Key STR
# - Value STR
# - PropagateAtLaunch BOOL
# - ResourceId STR
# - ResourceType STR
DescribeTags() #Request variables: Filter OBJ_ARR:
# - Name "auto-scaling-group|key|value|propagate-at-launch"
# - Value STR
#Response body: Tags TAG_ARR
#Paginates
/=+===============================+=\
/ : : \
)==: CLOUDFORMATION :==(
\ :_______________________________: /
\=+===============================+=/
CREATION_POLICY|UPDATE_POLICY #From CloudFormation (see its doc)
CREATION_POLICY
.MinSuccessfulInstancesPercent #Like UPDATE_POLICY, but on AUTOSCALING_GROUP creation instead
CREATION_POLICY #Like CREATION_POLICY.Count|Timeout with WAITCONDITION, but for EC2 instances inside an AUTOSCALING_GROUP
.ResourceSignal.Count|Timeout #Only with AutoScaling::AutoScalingGroup
UPDATE_POLICY #ROLLING_POLICY. Only for AutoScaling::AutoScalingGroup
.AutoScalingRollingUpdate #When changing AUTOSCALING_GROUP MinSize|MaxSize|DesiredCapacity, start|stop EC2 instances in batches
ROLLING_POLICY.MaxBatchSize #NUM (def: 1, max: 100) of EC2 instances at once
ROLLING_POLICY
.MinInstancesInService #Keep at least NUM (def: 0) EC2 instances up at any time
ROLLING_POLICY
.MinSuccessfulInstancesPercent #NUM% (def: 100). Consider update complete and successful once NUM% EC2 instances succeeded.
ROLLING_POLICY.PauseTime #TIME_DURATION. Def: 5m if WaitOnResourceSignals true, 0s otherwise. Max: 1h
#How long to wait for EC2 instances to start
ROLLING_POLICY
.WaitOnResourceSignals #BOOL (def: false). Wait for SIGNAL before considering EC2 instance started.
ROLLING_POLICY.SuspendProcesses #STR_ARR. Calls AutoScaling SuspendProcesses() temporarily,
#to prevent AutoScaling from interfering with CloudFormation
#STR_ARR is ScalingProcesses argument
UPDATE_POLICY #BOOL (def: false). Only for AutoScaling::AutoScalingGroup.
.AutoScalingReplacingUpdate #Replace AUTOSCALING_GROUP itself instead of its EC2 instances
.WillReplace #Old AUTOSCALING_GROUP and its EC2 instances are kept until completion, then deleted.
UPDATE_POLICY #BOOL. Only for AutoScaling::AutoScalingGroup.
.AutoScalingScheduledAction #When AUTOSCALING_GROUP MinSize|MaxSize|DesiredCapacity have:
.IgnoreUnmodifiedGroupSize # - not changed in TEMPLATE
Properties # - but changed in real (drift) due to a scheduled policy
#Whether to use the TEMPLATE value (false, def) or keep the real one (true).