With the end of year holidays coming up I'd like to schedule EC2 instances in a development environment to be turned off from say 20th December 8am to 5th Jan 5am. I'd also like to turn them off for other holidays, such as public holidays, of which we have about ten or so per year.
We're already using AWS Instance Scheduler to turn instances off evenings / weekends and on in the mornings. I have found a way to do this, but it means using multiple periods for each holiday, increasing complexity and the chance of making a mistake creating the schedule.
The way AWS Instance Scheduler works is you tell it the periods you want the instances turned on, based on a schedule. Each schedule can be associated with multiple on / off periods. For example you can have instances turned on at 8am and off at 6pm Monday to Friday, which leave the instances off on the weekends as well. I haven't been able to find a way to say "override the other schedules to turn the instances off these dates / times".
The closest I can find is to specify my on periods including month and day (aka monthdate). This is somewhat unwieldy and inelegant. For example our existing schedule is set up with the scheduler CLI like this
scheduler-cli create-period --name "8am-to-6pm-weekdays" --begintime 08:00 --endtime 18:00 --weekdays mon-fri --stack AwsInstanceScheduler
scheduler-cli create-schedule --name "dev-servers-on" --periods 8am-to-6pm-weekdays --stack AwsInstanceScheduler
The periods / schedule would look something like this if set up for the end of year holidays, and as an example, for a holiday 15th of March.
scheduler-cli create-period --name "8am-to-6pm-weekdays-jan" --begintime 08:00 --endtime 18:00 --weekdays mon-fri --months 1 --monthdays 5-31 --stack AwsInstanceScheduler
scheduler-cli create-period --name "8am-to-6pm-weekdays-dec" --begintime 08:00 --endtime 18:00 --weekdays mon-fri --months 12 --monthdays 1-20 --stack AwsInstanceScheduler
scheduler-cli create-period --name "8am-to-6pm-weekdays-march-1" --begintime 08:00 --endtime 18:00 --weekdays mon-fri --months 3 --monthdays 1-14 --stack AwsInstanceScheduler
scheduler-cli create-period --name "8am-to-6pm-weekdays-march-2" --begintime 08:00 --endtime 18:00 --weekdays mon-fri --months 3 --monthdays 16-31 --stack AwsInstanceScheduler
scheduler-cli create-period --name "8am-to-6pm-weekdays-other" --begintime 08:00 --endtime 18:00 --weekdays mon-fri --months 2-11 --stack AwsInstanceScheduler
scheduler-cli create-schedule --name "dev-servers-on" --periods 8am-to-6pm-weekdays-jan,8am-to-6pm-weekdays-dec,8am-to-6pm-weekdays-other,8am-to-6pm-weekdays-march-1,8am-to-6pm-weekdays-march-2 --stack AwsInstanceScheduler
Is there a more elegant way to do this with the current instance scheduler implementation? If not I might make a feature request to create "off periods" that override existing schedules.