CRON Expressions using EventBridge

ยท

2 min read

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!

Create a scheduled Orders Reconciliation rule

  1. Open the AWS Management Console for Event Bridge in a new tab.

  2. On the EventBridge homepage, select Rules from the left-hand menu.

  3. Select the default event bus and click the Create rule button.

    Scheduled Orders

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

  4. On the Create rule page:

  • Add OrdersReconciliation as the Name of the rule

  • Add Runs reconciliation routine on orders every minute Monday to Friday for Description

  • Select Schedule for Rule type

  • As we are still using the previous scheduler, you should click on the Continue to create rule button.

    DefineSchedule

  • In Schedule Pattern select the left option, which represnts a cron expression.

  • Add ? MON-FRI in the Cron expression.

    DefineSchedule

  • Configure your target to be a CloudWatch log group

    Name the log group /aws/events/orders_reconciliation

    SelectTarget

  • Click Next and finish walking through the rest of the walk-through to create the rule.

Verify scheduled message delivery

  1. Open the AWS Management Console for Cloud Watch Log Group.

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

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

    CloudWatchForSchedule

And thereby we have completed our Event Driven Architecture using Amazon Event Bridge!!!

Make sure that your terminate each of the service/resources to be safe from the unexpected surprise bill at the end of the month ๐Ÿ’€ !!

ย