Scheduling Expressions for Rules

You can create rules that self-trigger on an automated schedule in EventBridge using cron or rate expressions. All scheduled events use UTC time zone and the minimum precision for schedules is 1 minute.

EventBridge supports cron expressions and rate expressions. Rate expressions are simpler to define but don’t offer the fine-grained schedule control that cron expressions support. For example, with a cron expression, you can define a rule that triggers at a specified time on a certain day of each week or month. In contrast, rate expressions trigger a rule at a regular rate, such as once every hour or once every day.

Let’s give it a try!

Step 1: Create a scheduled Orders Reconciliation rule

  1. Open the AWS Management Console for EventBridge in a new tab or window, so you can keep this step-by-step guide open.

  2. On the EventBridge homepage, open the left hand navigation.

    EventBridge Console

  3. Select Rules from the left-hand menu.

  4. Click Create rule.

  5. On the Create rule page:

    • add OrdersReconciliation as the Name of the rule
    • add Runs reconciliation routine on orders every minute Monday to Sunday for Description
  6. Select Schedule from the Define pattern panel.

  7. Select Cron expression and enter * * ? * mon-sun *.

    Scheduled Expression

    This will schedule a message to be delivered every minute, Monday through Friday.

  8. Keep AWS default event bus selected as the event bus.

    You can only use a scheduled expression for the default event bus.

  9. Configure your target to be a CloudWatch log group

    • Name the log group /aws/events/ orders_reconciliation

    Scheduled Expression

  10. Leave the Tags blank.

    Create Bus

  11. Click Create.

Step 2: Verify scheduled message delivery

  1. Open the AWS Management Console for CloudWatch in a new tab or window, so you can keep this step-by-step guide open.

  2. Choose Log groups in the left navigation and select the /aws/events/orders_reconciliation log group.

  3. Verify that you have successfully created a rule and that the scheduled expression is successfully logging to the CloudWatch Log group you specified as a target.

    Verify Event rule

    After a few minutes your streams for /aws/events/orders_reconciliation should look similar to this:

    Verify Log Stream

    The cron expression can take up to 60 seconds to trigger. If you follow the steps below and do not see your event, refresh the Log streams. If you still have troubles verifying the event, please notify the workshop staff.

Congratulations

Congratulations, you have just completed your first scheduled expression for an Amazon EventBridge rule. Next, spend some time exploring integrating AWS Lambda Destinations with EventBridge.