Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events: cannot specify timezone for Schedule cron #21181

Open
2 tasks
maxhayward opened this issue Jul 16, 2022 · 18 comments
Open
2 tasks

Events: cannot specify timezone for Schedule cron #21181

maxhayward opened this issue Jul 16, 2022 · 18 comments
Labels
@aws-cdk/aws-events Related to CloudWatch Events effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@maxhayward
Copy link

maxhayward commented Jul 16, 2022

Describe the feature

In the console, when creating a Rule with an Event schedule, I have the option to use UTC or 'Local time zone'.

I can't seem to find a way of specifying this in CDK. It would be helpful if this is possible.

Here's my current implementation - if there's something I can add to this, that would be great.

const rule = new Rule(this.parent, `${this.stackName}-Rule-${ruleName}`, {
      ruleName: `${this.stackName}-${ruleName}`,
      schedule: Schedule.cron({
        minute: "0",
        hour: "8,20",
      }),
    });

Use Case

For timezones such as Europe/London, currently if I want the schedule to be consistent all year around I need to manually update this field in the console after creating the Rule via CDK.

Proposed Solution

An additional field, timeZone or similar.

const rule = new Rule(this.parent, ${this.stackName}-Rule-${ruleName}, {
ruleName: ${this.stackName}-${ruleName},
schedule: Schedule.cron({
minute: "0",
hour: "8,20",
timeZone: "Europe/London"
}),
});

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.32.0

Environment details (OS name and version, etc.)

MacOS Monterey 12.4

@maxhayward maxhayward added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 16, 2022
@github-actions github-actions bot added the @aws-cdk/aws-events Related to CloudWatch Events label Jul 16, 2022
@rix0rrr
Copy link
Contributor

rix0rrr commented Jul 25, 2022

All timezones in CDK are always UTC.

@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort p2 and removed needs-triage This issue or PR still needs to be triaged. labels Jul 25, 2022
@rix0rrr rix0rrr removed their assignment Jul 25, 2022
@alechewitt
Copy link

We wouldn't need AWS events to actually support timezone to support this. It could be achieved by creating multiple rules that trigger depending on the time of year.
An implementation similar to this: https://www.npmjs.com/package/serverless-local-schedule

@mdnorman
Copy link

Supposedly, EventBridge supports timezones, so there just needs to be a way to configure that timezone with CDK: https://aws.amazon.com/blogs/compute/introducing-amazon-eventbridge-scheduler/

@udlose
Copy link

udlose commented Apr 27, 2023

Apparently this exists in the aws_cdk.aws_autoscaling.CfnScheduledAction construct. It'd be nice to have it in the aws_cdk.aws_events.Schedule too.

Any updates on this?

@ShaneYen
Copy link

ShaneYen commented May 6, 2023

Was looking for this functionality as well. any workaround?

@DanielLaberge
Copy link

This really ought to be supported. It's a shame and is frustrating when CDK lags behind features offered in the Console.

@LucasSymons
Copy link

Time zones and Daylight savings support would be amazing!

@oxc
Copy link

oxc commented Jun 19, 2023

Seems like this will be supported in the AWS EventBridge Scheduler (Alpha) construct.

@micheleuno1
Copy link

as @oxc said, its actually supported by the alpha Scheduler, after some small troubles, i managed to schedule a Step Function using the correct Time Zone.

Copy link

This issue has received a significant amount of attention so we are automatically upgrading its priority. A member of the community will see the re-prioritization and provide an update on the issue.

@github-actions github-actions bot added p1 and removed p2 labels Jan 28, 2024
@moelasmar moelasmar self-assigned this Feb 8, 2024
mergify bot pushed a commit that referenced this issue Feb 15, 2024
Closes #22645
Closes #27754

Spiritual successor of #27052

Somewhat related to #21181 but that might be another PR down the road.

@pahud ✋ Please review. I'm not particularly fond of how `aws-autoscaling` module ([here](https://github.com/aws/aws-cdk/blob/256cca4017a80f8643c5f5a5999a2ce0383eebf0/packages/aws-cdk-lib/aws-autoscaling/lib/scheduled-action.ts#L21)) is not using `cdk.TimeZone` class, hence why used it in this PR instead. I think we should we change `aws-autoscaling` implementation to do the same? It would be a breaking change... and most likely a brand new PR. LMK what you think. ✌️ 

Also, I may be slightly OCD but I kinda like better `timezone` vs `timeZone`, but I went with latter one to follow what `aws-autoscaling` did.

cc-ing @kaizencc for his input too 🙌  ... possibly related to #27105

### Reason for this change



Timezones have been supported in `AWS::ApplicationAutoScaling::ScalableTarget ScheduledAction` for a while now.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-applicationautoscaling-scalabletarget-scheduledaction.html#cfn-applicationautoscaling-scalabletarget-scheduledaction-timezone


### Description of changes

Just added the support for `timezones` in `scalableTarget.scaleOnSchedule`

### Description of how you validated changes

Added unit tests for this feature.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
GavinZZ pushed a commit that referenced this issue Feb 22, 2024
Closes #22645
Closes #27754

Spiritual successor of #27052

Somewhat related to #21181 but that might be another PR down the road.

@pahud ✋ Please review. I'm not particularly fond of how `aws-autoscaling` module ([here](https://github.com/aws/aws-cdk/blob/256cca4017a80f8643c5f5a5999a2ce0383eebf0/packages/aws-cdk-lib/aws-autoscaling/lib/scheduled-action.ts#L21)) is not using `cdk.TimeZone` class, hence why used it in this PR instead. I think we should we change `aws-autoscaling` implementation to do the same? It would be a breaking change... and most likely a brand new PR. LMK what you think. ✌️ 

Also, I may be slightly OCD but I kinda like better `timezone` vs `timeZone`, but I went with latter one to follow what `aws-autoscaling` did.

cc-ing @kaizencc for his input too 🙌  ... possibly related to #27105

### Reason for this change



Timezones have been supported in `AWS::ApplicationAutoScaling::ScalableTarget ScheduledAction` for a while now.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-applicationautoscaling-scalabletarget-scheduledaction.html#cfn-applicationautoscaling-scalabletarget-scheduledaction-timezone


### Description of changes

Just added the support for `timezones` in `scalableTarget.scaleOnSchedule`

### Description of how you validated changes

Added unit tests for this feature.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@chenchanglew
Copy link

Thanks for the implementation of Timezone in ApplicationAutoscaling. But is that any plan of the implementation for the timezone in EventBridge as the title mention?

I have noticed that timezone support appears to be implemented in the JavaScript version of the AWS CDK, as detailed here: AWS CDK Scheduler library for JavaScript.

However, upon reviewing the Python AWS CDK documentation, particularly the Schedule class, I did not find any references to timezone support for EventBridge cron expressions.

Could you please provide information on whether there are plans to introduce timezone handling in EventBridge for the Python version of the AWS CDK? Additionally, if such functionality is already in development or available, I would greatly appreciate guidance on accessing and utilizing it.

@cbailiss
Copy link

It's incredible to me that the basic functionality to configure a scheduled fargate task using a local time via the Python CDK still appears to be missing. This is a basic feature requirement that AWS just appears to be completely ignoring.
Please could someone from AWS provide an update?

@Bozz95
Copy link

Bozz95 commented Apr 22, 2024

I'm also looking forward for the python CDK implementation of this feature.

@arm-diaz
Copy link

Also, looking for this feature

@kaijun11
Copy link

Need this ASAP

@jeff1evesque
Copy link

CloudFormation has AWS::Scheduler::Schedule, which supports ScheduleExpressionTimezone. I'm looking for something similar to events.CfnRule. Maybe by the time some of these "priority" tickets get attention, IAC will be obsolete with infrastructure as GPT (IAGPT).

@jeff1evesque
Copy link

Lucky me, looks like schedule_expression_timezone is part of scheduler.CfnSchedule. Probably not the same as most of you guys are looking for. But, if you want CFN variation of CDK, it's there, and fits my bill.

@moelasmar moelasmar removed their assignment Sep 8, 2024
@robertchinezon
Copy link

Hey I would like to continue activity on this ticket, I think CDK constructs should always have full feature parity with any other interface of the same service.

I am also on Python CDK, so I would like to see it added there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-events Related to CloudWatch Events effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

No branches or pull requests