Skip to content
← All labs
Serverless / Hands-on lab

Run a scheduled cloud task

Invoke a Lambda function with EventBridge Scheduler and trace the result in CloudWatch.

Beginner35 minutesUpdated 2026-09-23Use your own AWS learning account

Overview

A campus club wants a scheduled reminder task. Build the scheduling portion and verify a log entry. This lab deliberately does not send emails or messages to real people.

Architecture

EventBridge Scheduler assumes its execution role and invokes a Lambda function. Lambda uses a separate execution role to write logs to CloudWatch. These roles serve different purposes.

AWS Lambda service icon

Choose Scheduler for time-based invocations. Choose event routing when an action should happen because another application event occurred.

Prerequisites

  • Permission to create Lambda, its basic execution role, a schedule, and the schedule's target invocation role.
  • A learning account, one region, and access to CloudWatch logs.

Steps

1. Create the reminder function

Create cloudadhar-club-reminder using Python 3.12 and a new basic execution role. Use 128 MB memory and a three-second timeout. Deploy:

python
import json

def lambda_handler(event, context):
    print(json.dumps({
        "eventType": "club_reminder",
        "club": event.get("club", "cloud-club"),
        "requestId": context.aws_request_id
    }))
    return {"processed": True}

2. Verify a manual invocation

Test with {"club":"cloud-club"}. Confirm processed: true and locate the club_reminder entry in the function's log group. Record the timestamp so you can distinguish it from the later scheduled invocation.

3. Create a one-time schedule

In EventBridge Scheduler, create a one-time schedule called cloudadhar-reminder-once for at least five minutes in the future. Explicitly select and record the timezone. Turn off the flexible time window. Choose the Lambda Invoke target and select your function in the same region. Set the payload to {"club":"cloud-club"}.

Let the console create a new execution role for this schedule's target, or use an approved role limited to invoking this function. Review the target ARN and schedule time before saving. Disable retries for this disposable exercise if the console offers that setting.

4. Observe the scheduled run

After the selected minute, allow time for asynchronous delivery and inspect the log group. Find a new club_reminder event with a later timestamp than your manual invocation. Do not expect second-level scheduling precision.

5. Diagnose a missing invocation

Check the schedule is enabled, the timezone and selected date are correct, the target ARN is correct, and the schedule role is permitted to invoke it. Compare Scheduler monitoring with Lambda logs. Do not broaden permissions to administrator access.

Verification

  • Manual test produces a log event.
  • The scheduled invocation produces a separate log event at or after its scheduled minute.
  • You can explain the difference between the Scheduler role and Lambda role.
  • You can identify why production side effects should tolerate retries or duplicate delivery.

Cost and cleanup

Scheduler invocations, Lambda execution, and CloudWatch logs can incur charges. Delete the one-time schedule even after it has fired; completed schedules can remain unless configured for automatic deletion. Delete the function, its log group, and dedicated roles after confirming they are not shared.

References