- Newest
- Most votes
- Most comments
In Amazon EventBridge cron expressions, ranges are inclusive of both the start and end values. Hence, if you are defining hours as 9-13,14-19
the rule is active from 09:00 to 13:59 and 14:00 to 19:59 which effectively makes it active from 9:00 AM to 7:59 PM in Europe/Paris.
You can amend your cron expression to be cron(0/10 9-12,14-19 ? * MON-SAT *)
but it will miss the run at 13. If this run is important, I am not sure you can achieve so with a single cron expression but you could create just another one for 13 with the same Lambda function as a target.
The AWS web console displays the next 10 trigger dates when you define a cron expression, you can use that to confirm it runs when you want to.
@Hanna Hinn curious to know if the above helped. Cheers.
The behavior you're experiencing with AWS EventBridge Scheduler rules firing immediately after deployment, even outside the scheduled window, is not typical and suggests a potential misconfiguration or misunderstanding of how EventBridge Scheduler operates.
EventBridge Scheduler rules should only run at the times specified by their cron expressions. In your case, with the expression cron(0/10 9-13,14-19 ? * MON-SAT *), the rules should only trigger every 10 minutes between 9 AM-1 PM and 2 PM-7 PM on Monday through Saturday, in the Europe/Paris time zone.
To address this issue and prevent immediate firing after deployment, consider the following:
-
Double-check your cron expression: Ensure it accurately represents your intended schedule. The current expression looks correct based on your description.
-
Verify the time zone: Confirm that the Europe/Paris time zone is correctly set for each rule. Time zone mismatches can cause unexpected behavior.
-
Use flexible time windows: Consider implementing flexible time windows for your schedules. This feature allows EventBridge Scheduler to invoke targets within a specified time frame after the scheduled time, which can improve schedule reliability and potentially mitigate issues with immediate firing.
-
Check for default state: When creating or updating schedules, ensure that the state is set to ENABLED only when you want the schedule to be active. You might want to set it to DISABLED initially and enable it at an appropriate time.
-
Review your Terraform configuration: Although you mentioned that the schedulers are manually added, review your Terraform code to ensure it's not inadvertently triggering the schedulers or modifying their configurations during deployment.
-
Implement a delay: If the issue persists, you could implement a short delay or cool-down period after deployment before enabling the schedulers.
-
Monitor and log: Set up detailed logging and monitoring for your EventBridge Scheduler rules to track when and why they're being triggered. This can help identify any unexpected behavior.
If these steps don't resolve the issue, you may need to contact AWS support for further assistance, as this behavior is not standard for EventBridge Scheduler.
Sources
Configuring flexible time windows in EventBridge Scheduler - EventBridge Scheduler
Changing the schedule state in EventBridge Scheduler - EventBridge Scheduler
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 months ago
Hi, sorry for the confusion, I manage them manually from the console , The event sent is a custom event. The issue is that the cron is configured to not run at the time that i did the deployment but somehow after the deployement was done, i checked the logs and saw that the schedules were running. Went to check the schedules why they got triggered but nth was changed in them. And when i saw the next triggers. They were all in the unallowed time to call. To give you more context , the time that the schedulers was not supposed to trigger is between 1 and 2. Deployment happend at 1:30 , the schedulers triggered the lambdas at 1:40 then 1:50 then 2:00. Which is something that is not supposed to happen
Could you please clarify how you manage these schedulers? You first mention that you manage them in Terraform but then later that they are manually added outside Terraform?
What is the event that you receive when the Lambda function gets triggered?