I've looked all over the place, and can't find a good Amazon CloudFormation example of an Auto Scaling Group configured to add/remove capacity on a schedule.
Its certainly possible with the command line tools, but I can't find the corresponding CloudFormation language.
Anybody know how this is done?
Create an Auto Scaling group from an EC2 instance (console)Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . On the navigation pane, under Instances, choose Instances, and then select an instance. Choose Actions, Instance settings, Attach to Auto Scaling Group.
You first specify the common configuration parameters in a launch template, and choose it when you create an Auto Scaling group. When you configure the Auto Scaling group, you can: Choose one or more instance types for the group (optionally overriding the instance type that is specified by the launch template).
If you specify scaling policies, then Amazon EC2 Auto Scaling can launch or terminate instances as demand on your application increases or decreases. For example, the following Auto Scaling group has a minimum size of one instance, a desired capacity of two instances, and a maximum size of four instances.
We are pleased to announce that you can now create Auto Scaling groups based on running instances and attach running instances to existing groups.
AWS CloudFormation sometimes doesn't cover all (new) API actions available within other AWS Products & Services, though they usually get introduced within a few month later on.
Unfortunately, despite Scale Based on a Schedule being introduced in December 2010 already, this feature is still not supported as of today, see Eric Hammond's recent Request: CloudFormation support for Auto Scaling schedules and suspend from January 2013 - the AWS team response is unusually sparse here (while never announcing dates, they often hint on priorities at least), thus it doesn't look promising exactly - accordingly you'll need to work around it for the time being.
You might be able to integrate a custom workaround with CloudFormation still by means of the dedicated CustomResource type, which are special AWS CloudFormation resources that provide a way for a template developer to include resources in an AWS CloudFormation stack that are provided by a source other than Amazon Web Services. - the AWS CloudFormation Custom Resource Walkthrough provides a good overview of what this is all about, how it works and what's required to implement your own.
Your custom resource would need to implement the missing support for scheduled actions by explicitly calling the PutScheduledUpdateGroupAction API, you could then integrate this resource in your template to complement (or even replace) the as of yet insufficient official ScalingPolicy resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With