Repository navigation
feat(aws-node-scheduled-cron,aws-python-scheduled-cron): add a weekday cron in a time zone with EventBridge Scheduler - #842
Merged
Conversation
…y cron in a time zone with EventBridge Scheduler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lesson
The two scheduled-cron onboarding examples now show both schedule forms side by side:
rateHandler(unchanged):rate(1 minute)through an EventBridge rule, the default, which evaluates cron in UTC.cronHandler(new):cron(0 9 ? * MON-FRI *)withmethod: schedulerandtimezone: America/New_York, so EventBridge Scheduler runs it at 9 AM New York time on weekdays.The README's How it works explains rate() vs cron() (six fields, the
?rule for day of month / day of week), EventBridge rules vs EventBridge Scheduler withtimezone, and Try it showsserverless invoke --function cronHandler --logto run the cron function without waiting for 9 AM.Left out:
input,name,enabled: false, flexible time windows and schedule groups (all on the schedule event docs page), and a custom role for Scheduler.Changes
Both examples, matched:
serverless.yml: a second function,cronHandler, with the scheduler/timezonescheduleevent.handler.js/handler.py: acronhandler in the style of the existingrun, loggingYour weekday cron function ran at ....example.json: a secondinvokecheck oncronHandlerwith--log, assertingYour weekday cron function ran at(text only the new handler writes; the existing line isYour cron function ran at).servicesaddsscheduler;descriptionmentions the weekday run.README.md: intro, What it deploys, Deploy output, Try it (invokecronHandler), How it works, Cost and cleanup (Scheduler invocations), Next steps wording. Output blocks are from real runs on CLI 4.47.0 with stage shown asdev.README.mdandexamples.jsondescriptions (npm run docs).These are onboarding examples. Files touched beyond
README.mdandexample.json:aws-node-scheduled-cron/serverless.yml,aws-node-scheduled-cron/handler.js,aws-python-scheduled-cron/serverless.yml,aws-python-scheduled-cron/handler.py.Test plan
us-east-1, Framework 4.47.0.Live test of the examples as committed:
Negative control (scratch copies with the new check expecting
Your weekday cron function ran on Saturday), both stopped at thecheckstep onchecks[1]afterchecks[0]passed:README followed by hand from copies (deploy, invoke both functions,
invoke localfor Python, remove). The deployed schedule read back asScheduleExpression: cron(0 9 ? * MON-FRI *),ScheduleExpressionTimezone: America/New_York, groupdefault, target role the function role.Fresh-agent test, both examples: an agent given only the README deployed the example, ran Try it (
serverless invoke --function cronHandler --logloggedYour weekday cron function ran at ...; for Python alsoserverless invoke local), removed it and confirmed the stack was gone.Nothing left after the runs: no stack, EventBridge Scheduler schedule, EventBridge rule, log group or IAM role from the examples.
npm test(323 pass),npm run validate(0 errors),npm run docs,npm run check-docs,check-examples.mjs --packageon both. Neither example has apackage.json.Generated by Claude Code