Skip to content

Instantly share code, notes, and snippets.

@lvthillo
Last active June 10, 2019 15:06
Show Gist options
  • Save lvthillo/b6f3ac5b29af546ed6ea6ccdf8ffe6ef to your computer and use it in GitHub Desktop.
Save lvthillo/b6f3ac5b29af546ed6ea6ccdf8ffe6ef to your computer and use it in GitHub Desktop.
Scaling Policy and Alarms
ScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: !Ref ASG
Cooldown: '1'
ScalingAdjustment: 1
ScaleDownPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName: !Ref ASG
Cooldown: '1'
ScalingAdjustment: -1
MemoryAlarmHigh:
Type: AWS::CloudWatch::Alarm
Properties:
EvaluationPeriods: 1
Statistic: Average
Threshold: 70
AlarmDescription: Go in Alarm is memory is higher than 70% for 60 seconds
Period: 60
AlarmActions:
- Ref: ScaleUpPolicy
Namespace: CWAgent
Dimensions:
- Name: AutoScalingGroupName
Value: !Ref ASG
ComparisonOperator: GreaterThanThreshold
MetricName: mem_used_percent
MemoryAlarmLow:
Type: AWS::CloudWatch::Alarm
Properties:
EvaluationPeriods: 1
Statistic: Average
Threshold: 30
AlarmDescription: Go in Alarm is memory is lower than 30% for 60 seconds
Period: 60
AlarmActions:
- Ref: ScaleDownPolicy
Namespace: CWAgent
Dimensions:
- Name: AutoScalingGroupName
Value: !Ref ASG
ComparisonOperator: LessThanOrEqualToThreshold
MetricName: mem_used_percent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment