Skip to content

feat(aws-node-scheduled-cron,aws-python-scheduled-cron): add a weekday cron in a time zone with EventBridge Scheduler - #842

Merged
czubocha merged 3 commits into
v4from
branch/dreamy-lamport-709whe-cron-tz
Nov 25, 2026
Merged

czubocha merged 3 commits into
v4from
branch/dreamy-lamport-709whe-cron-tz

Conversation

@czubocha

Copy link
Copy Markdown
Contributor

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 *) with method: scheduler and timezone: 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 with timezone, and Try it shows serverless invoke --function cronHandler --log to 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/timezone schedule event.
  • handler.js / handler.py: a cron handler in the style of the existing run, logging Your weekday cron function ran at ....
  • example.json: a second invoke check on cronHandler with --log, asserting Your weekday cron function ran at (text only the new handler writes; the existing line is Your cron function ran at). services adds scheduler; description mentions the weekday run.
  • README.md: intro, What it deploys, Deploy output, Try it (invoke cronHandler), 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 as dev.
  • Generated: root README.md and examples.json descriptions (npm run docs).

These are onboarding examples. Files touched beyond README.md and example.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:

    PASS aws-node-scheduled-cron 4.47.0 182s     (stage exo5qhdefda)
    PASS aws-python-scheduled-cron 4.47.0 182s   (stage exo5qhaeqo8)
    
  • Negative control (scratch copies with the new check expecting Your weekday cron function ran on Saturday), both stopped at the check step on checks[1] after checks[0] passed:

    FAIL _neg-node-cron 4.47.0 186s      (stage exnt1ueg739, failedStep check: checks[1] invoke: serverless invoke -f cronHandler: output does not contain "Your weekday cron function ran on Saturday")
    FAIL _neg-python-cron 4.47.0 185s    (stage exnt1ud25eq, same)
    
  • README followed by hand from copies (deploy, invoke both functions, invoke local for Python, remove). The deployed schedule read back as ScheduleExpression: cron(0 9 ? * MON-FRI *), ScheduleExpressionTimezone: America/New_York, group default, 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 --log logged Your weekday cron function ran at ...; for Python also serverless 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 --package on both. Neither example has a package.json.


Generated by Claude Code

@czubocha
czubocha merged commit f2b1e88 into v4 Nov 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant