Schedule your Amazon EC2 spot instance startup time
January 16, 2013
Posted by on
Here I want to explain how to start your Amazon EC2 instance recurrently by scheduling.
I have used the AWS Tools for Windows PowerShell. You can use java command line or python library. The main goal is to explain the idea:
I am going to automate the starting of my Fitnesse server.
Create launch configuration
New-ASLaunchConfiguration Fitnesse -ImageId ami-00000000 -SecurityGroups Fitnesse -InstanceType t1.micro -SpotPrice 0.011
Create Auto Scaling group with MinSize=MaxSize=0
New-ASAutoScalingGroup Fitnesse-AS -LaunchConfigurationName Fitnesse -AvailabilityZones us-east-1a -MinSize 0 -MaxSize 0
Set the Start scheduling action
The core thing is the MinSize=MaxSize=1 and the -Recurrence argument which is in the cron scheduler time format
Write-ASScheduledUpdateGroupAction -AutoScalingGroupName Fitnesse-AS -ScheduledActionName Start -MinSize 1 -MaxSize 1 -Recurrence '15 13 * * *'
Optionl (stop event)
Write-ASScheduledUpdateGroupAction -AutoScalingGroupName Fitnesse-AS -ScheduledActionName Stop -MinSize 0 -MaxSize 0 -Recurrence '59 23 * * *'