Scheduled Events

Jets supports Scheduled Events. This allows you to have a Lambda function run on a scheduled based. The scheduled event is a Amazon EventBridge rule.


Generate code.

jets generate:event cool --trigger scheduled

It looks something like this.


class CoolEvent < ApplicationEvent
  rate "10 hours"
  def handle
    puts "Do something with event #{JSON.dump(event)}"

You can use cron-like expressions

cron(0 12 * * ? *)            # runs every day at 12:00pm UTC
cron(5,35 14 * * ? *)         # runs every day, at 2:05pm and 2:35pm UTC
cron(15 10 ? * 6L 2019-2022)  # runs at 10:15am UTC on the last Friday of
                              # each month during the years 2019 to 2022

** Note **: The [AWS Cron] ( syntax is slightly different from the Linux cron syntax. The AWS Cron format has six required fields, which is slightly different from the traditional Linux cron format, which has five fields. There’s also a ? notation, which means any day of the month.

You can also use rate expresions

rate(1 minute)
rate(5 minutes)
rate(1 hour)
rate(1 day)

Note: Notice the singular 1 minute vs plural 5 minutes.

Jets 6 and above also uses fugit internally to allow user-friendly expressions like 5m to 5 minutes.

Tailing Logs

It helps to tail the logs and watch the event as it comes through.

jets logs -f -n cool_event-handle

Event Payloads

The event payload from the Scheduled Event is pretty simple.


  "version": "0",
  "id": "3a0b6d51-b30a-7d45-1468-acc58fff5558",
  "detail-type": "Scheduled Event",
  "source": "",
  "account": "1122334455",
  "time": "2023-12-24T15:48:05Z",
  "region": "us-west-2",
  "resources": [
  "detail": {}