CRON Expressions using EventBridge
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
Open the AWS Management Console for Event Bridge in a new tab.
On the EventBridge homepage, select Rules from the left-hand menu.
Select the default event bus and click the Create rule button.
Note : You can only use a scheduled expression for the default event bus.
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.
In Schedule Pattern select the left option, which represnts a cron expression.
Add ? MON-FRI in the Cron expression.
Configure your target to be a CloudWatch log group
Name the log group /aws/events/orders_reconciliation
Click Next and finish walking through the rest of the walk-through to create the rule.
Verify scheduled message delivery
Choose Log groups in the left navigation and select the /aws/events/orders_reconciliation log group.
After a few minutes your streams for /aws/events/orders_reconciliation should look similar to this:
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 ๐ !!
Subscribe to my newsletter
Read articles from Adil Shaikh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Adil Shaikh
Adil Shaikh
Adil a final year Computer Science student poised to make a mark in the tech world. With a diverse experience in the field of Cloud ,MLOPS and AWS tool's and technologies, Adil navigates the intersection of academia and real-world tech challenges. Driven by a passion for innovation, Adil expands skills into DevOps, mastering Linux, Docker, and Kubernetes. This journey culminates in securing an internship at AI Planet, specializing in MLOps. Adil's impactful contributions include optimizing GenAI stack deployment with Terraform, Ansible, and implementing creative solutions like KEDA, Prometheus & Grafana to reduce model cold start times. These experiences mark the beginning of a promising career journey for Adil, blending technical prowess with a passion for tackling real-world challenges.