Skip to content

Instantly share code, notes, and snippets.

@omerxx
Created November 6, 2017 19:15
Show Gist options
  • Select an option

  • Save omerxx/0eee345271d78dcea1b4931b1085e04e to your computer and use it in GitHub Desktop.

Select an option

Save omerxx/0eee345271d78dcea1b4931b1085e04e to your computer and use it in GitHub Desktop.
Resources:
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Ref EnvironmentName
ECSAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier: !Ref Subnets
LaunchConfigurationName: !Ref ECSLaunchConfiguration
MinSize: !Ref MinSize
MaxSize: !Ref MaxSize
DesiredCapacity: !Ref ClusterSize
Tags:
- Key: Name
Value: !Sub ${EnvironmentName} ECS host
PropagateAtLaunch: true
CreationPolicy:
ResourceSignal:
Timeout: PT15M
UpdatePolicy:
AutoScalingRollingUpdate:
MinInstancesInService: !Ref RollingUpdateMinInstInService
MaxBatchSize: !Ref RollingUpdateMaxBatchSize
PauseTime: PT15M
WaitOnResourceSignals: true
ECSScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: !Ref ECSAutoScalingGroup
Cooldown: '180'
ScalingAdjustment: '1'
MemoryAlarmHigh:
Type: AWS::CloudWatch::Alarm
Properties:
EvaluationPeriods: '1'
Statistic: Sum
Threshold: '70'
AlarmDescription: Alarm if cluster is holding less memory than scaleable
Period: '60'
AlarmActions:
- Ref: ECSScaleUpPolicy
Namespace: AWS/ECS
Dimensions:
- Name: ClusterName
Value:
Ref: ECSCluster
ComparisonOperator: GreaterThanThreshold
MetricName: MemoryReservation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment