maniSHarma7575 / hibernate

Auto Shutdown and Start Amazon EC2 Instance
3 stars 0 forks source link

[FEATURE] Node command add flag for the timezone for the cron. #2

Open maniSHarma7575 opened 16 hours ago

maniSHarma7575 commented 16 hours ago

Problem

As of now the cron schedule using the command below is scheduled always in the UTC timezone. We have to provide the option to the user to set the timezone of their choice using the flag --tz=UTC.

bin/hibernate node --in=<instance_name> --start_instance="<cron>" --stop_instance="<cron>"

Acceptance Criteria

maniSHarma7575 commented 9 hours ago

Research:

Aws::CloudWatchEvents::Client#put_rule method doesn't have an option to pass the timezone with schedule expression.

https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_PutRule.html

https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/CloudWatchEvents/Client.html#put_rule-instance_method

Hence we can't find help directly from AWS. Now question is do we want the parser in between to convert the cron expression from the user specified timezone to the UTC before giving it to put_rule API?

maniSHarma7575 commented 8 hours ago

AWS EventBridge cron expressions have specific allowed values, and we need to handle the edge cases and constraints of AWS EventBridge cron expressions more carefully.

Hence it would be better if we keep the UTC for now and target this issue in next milestone (0.2.0) as it required good amount of effort.

https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-use-sam.html