Scheduling Serverless Cron Jobs with Amazon EventBridge
Naveen Teja
2/27/2026

In the modern cloud-native ecosystem, managing scheduled tasks using traditional cron jobs on EC2 instances is an outdated anti-pattern. Not only does it require maintaining an always-on server, but it also introduces a single point of failure into your architecture. This is where Amazon EventBridge (formerly CloudWatch Events) completely revolutionizes task scheduling for DevOps engineers.
EventBridge acts as a central serverless event bus. It allows you to build event-driven architectures by connecting application data from your own apps, SaaS, and AWS services. However, one of its most powerful and frequently used features is its ability to trigger serverless compute—specifically AWS Lambda—on a rigid, reliable schedule without provisioning a single piece of infrastructure.
From a business perspective, the cost savings are massive. Instead of paying 24/7 for a t3.micro instance just to run a database cleanup script once a day, you only pay for the exact milliseconds the Lambda function executes. This pattern is essential for daily automated database backups, generating nightly analytics reports, or purging stale cache data across your CDN.
To implement this robust architecture, we define the infrastructure as code using Terraform. The process requires two primary resources: an Event Rule that defines the cron schedule, and an Event Target that links that rule to our Lambda function. Below is the exact Terraform configuration required to deploy a midnight UTC database cleanup trigger.
resource "aws_cloudwatch_event_rule" "daily_cleanup" {
name = "daily-database-cleanup"
description = "Fires every day at midnight UTC"
schedule_expression = "cron(0 0 * * ? *)"
}
resource "aws_cloudwatch_event_target" "trigger_lambda" {
rule = aws_cloudwatch_event_rule.daily_cleanup.name
target_id = "CleanupLambda"
arn = aws_lambda_function.cleanup.arn
}You might also like

Migrating from EC2 to AWS Fargate: A Step-by-Step Guide

Multi-Region Active-Active Architecture on AWS

Implementing AWS GuardDuty with Automated Threat Response

OpenTofu vs Terraform in 2024: Migration Guide and Key Differences

Zero-Trust Networking on AWS with IAM Identity Center and SCPs
