-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathApplicationAutoScalingSample.py
More file actions
44 lines (38 loc) · 1.04 KB
/
ApplicationAutoScalingSample.py
File metadata and controls
44 lines (38 loc) · 1.04 KB
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
from troposphere import Ref, Template
from troposphere.applicationautoscaling import (
ScalableTarget,
ScalingPolicy,
StepAdjustment,
StepScalingPolicyConfiguration,
)
t = Template()
scalable_target = ScalableTarget(
"scalableTarget",
MaxCapacity=2,
MinCapacity=1,
ResourceId="service/ecsStack",
RoleARN="Access Management (IAM) role",
ScalableDimension="ecs:service:DesiredCount",
ServiceNamespace="ecs",
)
scaling_policy = ScalingPolicy(
"scalingPolicy",
PolicyName="AStepPolicy",
PolicyType="StepScaling",
ScalingTargetId=Ref(scalable_target),
StepScalingPolicyConfiguration=StepScalingPolicyConfiguration(
AdjustmentType="PercentChangeInCapacity",
Cooldown=60,
MetricAggregationType="Average",
StepAdjustments=[
StepAdjustment(
MetricIntervalLowerBound=0,
ScalingAdjustment=200,
),
],
),
)
t = Template()
t.add_resource(scalable_target)
t.add_resource(scaling_policy)
print(t.to_json())