This Lambda function control-plane can scale-up or scale-down aws auto scaling group automatically by specific a given schedule.
Let's deploy this function using Serverless framework.
1st, install serverless framework:
$ npm install -g serverless
Set-up your AWS Provider Credentials
$ aws configure
In order to deploy the function simply run
$ serverless deploy
Simple add or remove cloudwatch schedule event in the serverless.yml with the required parameters: AsgGroupName
, MinSize
and DesiredCapacity
For example:
functions:
scale-asg:
events:
- schedule:
description: 'Scale-Down: Schedule at 7pm GMT+8 Mon-Fri'
rate: cron(0 11 ? * MON-FRI *)
enabled: true
input:
AsgGroupName: sitapp-AutoScaleGrp-XL7APL96YQPQ
MinSize: 0
DesiredCapacity: 0
- schedule:
description: 'New event'
...