aws-solutions / instance-scheduler-on-aws

A cross-account and cross-region solution that allows customers to automatically start and stop EC2 and RDS Instances

Home Page:https://aws.amazon.com/solutions/implementations/instance-scheduler-on-aws/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create Period WIth Monthdays Failed

Idosegal opened this issue · comments

Could you please clairify why this command failed? With the following error:
Error: 24-6 is not a valid month days specification

instance-scheduler-cli-runner.py create-period --name test-workdays-period --monthdays 24-6 --months 7-8 --stack instance-scheduler --region us-east-1

hi @Idosegal
did you mean to use 2,4-6? (note the comma)

without the comma, Instance Scheduler is processing the monthdays as the 24th-6th, but it expects the first day in a range to be the smaller value (so it is expecting 6-24)

Hi @CrypticCabub,

Thank you for your response.

I meant 24-6.
And to be more clear, 24/07-06/08.
The above range isn't working as you mentioned that it expected the first day to be a smaller value.
Is there no way to achieve that without specifying two periods?

you would need 2 periods for that scenario, yes. The monthday and month fields act like filters that are independently applied to the current date:

  • monthday filters for specific days in the month
  • month filters for specific months

If you want to specify different sets of days in different months, you would need to create a separate period for each unique set of days. For example:

  • --monthdays 24-L --months 7 for the 24th through to the end of July
  • --monthdays 1-6 --months 8 for the first 6 days of August

@CrypticCabub Thanks you.
You think it can be supported?
I can take it.

automatically recognizing that 24-6 refers to 7/26-8/6 is not really possible to do reliably.

Consider the case where you pass in 24-6 for monthdays and 7-9 for months. Which of the following is the correct set of running periods:

  • 7/26-9/6
  • 7/26-8/6, 8/26-9/6

it's impossible to know for sure

For instance scheduler, the correct way to handle scenarios like this is to apply multiple periods to the same schedule. complicated schedules like this can be hard to maintain using the CLI, but are much more managable using Infrastructure as Code via the CloudFormation custom resource. Take a look at the example I gave on #468 (comment) to see an example of how you can manage multiple complex periods like this easily.