Skip to content

Instantly share code, notes, and snippets.

@Benjamin-Connelly
Last active April 13, 2018 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Benjamin-Connelly/02aea83d84b7f5c4b682cb41626d1f36 to your computer and use it in GitHub Desktop.
Save Benjamin-Connelly/02aea83d84b7f5c4b682cb41626d1f36 to your computer and use it in GitHub Desktop.
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Sub ${AWS::StackName}
ECSAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier:
- Fn::ImportValue: !Sub '${VPCStackName}-${SubnetType}SubnetList'
LaunchConfigurationName: !Ref ECSLaunchConfiguration
MetricsCollection:
-
Granularity: "1Minute"
Metrics:
- "GroupMinSize"
- "GroupMaxSize"
MinSize: !Ref MinSize
MaxSize: !Ref MaxSize
DesiredCapacity: !Ref Desired
TerminationPolicies:
- Default
Tags:
- Key: Name
Value: !Sub ${AWS::StackName} ECS host
PropagateAtLaunch: true
CreationPolicy:
ResourceSignal:
Timeout: PT5M
UpdatePolicy:
AutoScalingRollingUpdate:
MinInstancesInService: 1
MaxBatchSize: 1
PauseTime: PT5M
WaitOnResourceSignals: true
ScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: !Ref ECSAutoScalingGroup
EstimatedInstanceWarmup: 300
MetricAggregationType: Average
PolicyType: StepScaling
StepAdjustments:
# The X bound is the difference between the breach threshold and the
# aggregated CloudWatch metric value
- MetricIntervalLowerBound: "0"
MetricIntervalUpperBound: "15"
ScalingAdjustment: "1"
- MetricIntervalLowerBound: "15"
ScalingAdjustment: "2"
ScaleDownPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: !Ref ECSAutoScalingGroup
EstimatedInstanceWarmup: 300
MetricAggregationType: Average
PolicyType: StepScaling
StepAdjustments:
# The X bound is the difference between the breach threshold and the
# aggregated CloudWatch metric value
- MetricIntervalUpperBound: "0"
ScalingAdjustment: "-1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment