Deploy Free Cron Jobs on AWS Lambda Without Paying for EventBridge Scheduler

Most developers think you must pay for AWS EventBridge Scheduler or CloudWatch Events to run cron jobs on AWS Lambda. But there's a clever way to deploy completely free, production-grade cron jobs using only AWS services you already have access to. Here's how. Step 1: Create a Scheduled Rule Using Basic EventBridge (Not Scheduler) You don't need "Scheduler" (which is a paid service). The free-tier "EventBridge Rules" can trigger Lambdas on a cron schedule. Go to AWS Console → EventBridge → Rules → Create Rule. Set up: Rule Type: Schedule Schedule Expression: Use cron syntax Example: cron(0 9 * * ? *) — runs daily at 9:00 AM UTC Then set the Target to your Lambda function. Example via AWS CLI Prefer IaC? Here's how to create it with AWS CLI: aws events put-rule \ --name "DailyJobRule" \ --schedule-expression "cron(0 9 * * ? *)" \ --state ENABLED And set the permission so EventBridge can invoke your Lambda: aws lambda add-permission \ --function-name MyLambdaFunction \ --statement-id EventInvokePermission \ --action 'lambda:InvokeFunction' \ --principal events.amazonaws.com \ --source-arn arn:aws:events:REGION:ACCOUNT_ID:rule/DailyJobRule Then attach the rule to the Lambda: aws events put-targets \ --rule "DailyJobRule" \ --targets "Id"="1","Arn"="arn:aws:lambda:REGION:ACCOUNT_ID:function:MyLambdaFunction" Step 2: Ensure Your Lambda Timeout and Memory are Reasonable Scheduled functions often have different needs than API functions. ✅ Set timeout high enough (e.g., 1–3 minutes) ✅ Set memory high enough for any bursts during cron execution This keeps your scheduled Lambda fast and reliable. Step 3: Bonus — Run Multiple Cron Jobs from a Single Lambda If you want different scheduled tasks, you don't need a new Lambda each time. Instead, you can route based on the rule name inside your Lambda: exports.handler = async (event) => { const invokedBy = event.resources[0]; // The EventBridge Rule ARN if (invokedBy.includes('DailyJobRule')) { await doDailyTask(); } else if (invokedBy.includes('HourlyCleanupRule')) { await doHourlyCleanup(); } }; async function doDailyTask() { // Your daily job logic } async function doHourlyCleanup() { // Your hourly job logic } ✅ Pros: No extra AWS costs for scheduling. Infrastructure scales elastically — no EC2, no containers. Extremely reliable; EventBridge is a managed service. ⚠️ Cons: Cron expressions are limited compared to complex scheduling needs (e.g., chaining dependent jobs). Cold starts can still occur if the Lambda isn’t invoked often. Summary You don’t need to pay for EventBridge Scheduler or rely on EC2 hacks to run scheduled jobs in AWS. By using basic EventBridge Rules, you can trigger Lambda functions on a cron schedule completely free — up to 100,000 invocations per month. This makes it ideal for startups, indie projects, or internal tools that don’t justify the extra cost of managed schedulers. Combined with clever routing inside a single Lambda, you can manage multiple cron jobs in one place without extra overhead. It’s a low-cost, high-leverage technique that most developers overlook — and it works great in production. If this was helpful, you can support me here: Buy Me a Coffee ☕

Apr 29, 2025 - 06:57
 0
Deploy Free Cron Jobs on AWS Lambda Without Paying for EventBridge Scheduler

Most developers think you must pay for AWS EventBridge Scheduler or CloudWatch Events to run cron jobs on AWS Lambda.

But there's a clever way to deploy completely free, production-grade cron jobs using only AWS services you already have access to.

Here's how.

Step 1: Create a Scheduled Rule Using Basic EventBridge (Not Scheduler)

You don't need "Scheduler" (which is a paid service). The free-tier "EventBridge Rules" can trigger Lambdas on a cron schedule.

Go to AWS Console → EventBridge → Rules → Create Rule.

Set up:

  • Rule Type: Schedule
  • Schedule Expression: Use cron syntax
    • Example: cron(0 9 * * ? *) — runs daily at 9:00 AM UTC

Then set the Target to your Lambda function.

Example via AWS CLI

Prefer IaC? Here's how to create it with AWS CLI:

aws events put-rule \
  --name "DailyJobRule" \
  --schedule-expression "cron(0 9 * * ? *)" \
  --state ENABLED

And set the permission so EventBridge can invoke your Lambda:

aws lambda add-permission \
  --function-name MyLambdaFunction \
  --statement-id EventInvokePermission \
  --action 'lambda:InvokeFunction' \
  --principal events.amazonaws.com \
  --source-arn arn:aws:events:REGION:ACCOUNT_ID:rule/DailyJobRule

Then attach the rule to the Lambda:

aws events put-targets \
  --rule "DailyJobRule" \
  --targets "Id"="1","Arn"="arn:aws:lambda:REGION:ACCOUNT_ID:function:MyLambdaFunction"

Step 2: Ensure Your Lambda Timeout and Memory are Reasonable

Scheduled functions often have different needs than API functions.

✅ Set timeout high enough (e.g., 1–3 minutes)

✅ Set memory high enough for any bursts during cron execution

This keeps your scheduled Lambda fast and reliable.

Step 3: Bonus — Run Multiple Cron Jobs from a Single Lambda

If you want different scheduled tasks, you don't need a new Lambda each time.

Instead, you can route based on the rule name inside your Lambda:

exports.handler = async (event) => {
  const invokedBy = event.resources[0]; // The EventBridge Rule ARN
  
  if (invokedBy.includes('DailyJobRule')) {
    await doDailyTask();
  } else if (invokedBy.includes('HourlyCleanupRule')) {
    await doHourlyCleanup();
  }
};

async function doDailyTask() {
  // Your daily job logic
}

async function doHourlyCleanup() {
  // Your hourly job logic
}

Pros:

  • No extra AWS costs for scheduling.
  • Infrastructure scales elastically — no EC2, no containers.
  • Extremely reliable; EventBridge is a managed service.

⚠️ Cons:

  • Cron expressions are limited compared to complex scheduling needs (e.g., chaining dependent jobs).
  • Cold starts can still occur if the Lambda isn’t invoked often.

Summary

You don’t need to pay for EventBridge Scheduler or rely on EC2 hacks to run scheduled jobs in AWS.

By using basic EventBridge Rules, you can trigger Lambda functions on a cron schedule completely free — up to 100,000 invocations per month. This makes it ideal for startups, indie projects, or internal tools that don’t justify the extra cost of managed schedulers. Combined with clever routing inside a single Lambda, you can manage multiple cron jobs in one place without extra overhead.

It’s a low-cost, high-leverage technique that most developers overlook — and it works great in production.

If this was helpful, you can support me here: Buy Me a Coffee