Study guide
Technical reference and lesson notes
Purpose of This Lesson
This hands-on lesson demonstrates how to create an Amazon EventBridge schedule that invokes an AWS Lambda function at a specified date and time. The Lambda function receives a JSON event payload and writes the message to CloudWatch Logs, providing a simple way to verify that the scheduled invocation succeeded.
The workflow is:
- Create a Lambda function.
- Deploy code that prints the received event.
- Create an EventBridge schedule with a future date, time, and time zone.
- Configure Lambda as the target and provide a JSON payload.
- Allow the schedule to create the required invocation role.
- Confirm execution in the Lambda CloudWatch Logs view.
- Remove the schedule and function when the exercise is complete.
Key Concepts
EventBridge schedule
An EventBridge schedule invokes a target at a configured time. In this exercise, the schedule is configured for a specific future date and time rather than demonstrated as a recurring schedule.
Important schedule settings include:
- Schedule name: Identifies the schedule.
- Schedule group: The default group can be used for this simple exercise.
- Date and time: The configured time must be in the future when the schedule is created.
- Time zone: Determines how the configured time is interpreted.
- Flexible time window: Disabled in the exercise so the invocation is not intentionally given a flexible execution window.
- Target: The AWS service invoked by the schedule—in this case, Lambda.
- Input payload: JSON data passed to the target.
- Action after completion: Set to keep the schedule rather than delete it automatically.
Lambda target
The Lambda function acts as the scheduled target. Its Python code prints the event it receives. Lambda then writes that output to CloudWatch Logs, allowing the event payload to be inspected after invocation.
Execution permissions
The Lambda function uses an execution role with permission to write to CloudWatch Logs. EventBridge also needs permission to invoke the Lambda target; during schedule creation, the console can create a new role for this purpose.
CloudWatch Logs verification
A log group or log stream may not exist before the function has run. After the first successful invocation, Lambda creates the relevant logging resources and the event output can be viewed through Monitor → View CloudWatch logs.
Scheduled Lambda Invocation Workflow
1. Create the Lambda function
Create a function named something like EventbridgeSchedule and select Python. The specific current Python version is not the important part of this exercise; the function must be able to run the supplied script.
Use the default execution role if it provides the required CloudWatch Logs permissions. For this demonstration, the function only needs to print the received event.
A simplified handler concept is:
def lambda_handler(event, context):
print(event)
Deploy the updated code before configuring the schedule.
2. Prepare the event payload
The schedule sends the configured input to Lambda. The payload must remain valid JSON. If changing the sample message, edit the value inside the quotation marks without breaking the JSON structure.
Example payload:
{
"message": "hello from EventBridge"
}
The Lambda function prints the received object, so the message should appear in its CloudWatch Logs output.
3. Create the EventBridge schedule
From the EventBridge console, open the schedules area and create a schedule. Configure the following:
- Give the schedule a descriptive name, such as
eventbridge-scheduled. - Leave the schedule group as the default group.
- Select a date and time a few minutes in the future.
- Choose the appropriate time zone.
- Use the 24-hour time format shown by the console.
- Leave the flexible time window disabled.
The future time is operationally important. If schedule creation or configuration takes longer than expected and the selected time has passed, update the schedule before waiting for the invocation.
4. Configure the target
Choose AWS Lambda as the target, select the function, and paste the JSON payload. Leave the other settings unchanged unless the use case requires a different configuration.
When prompted for permissions, choose the option to create a new role. This gives the schedule the permissions required to invoke the selected Lambda function.
Set the action after the schedule completes to none so that the schedule is not deleted automatically. This is useful when you want to inspect or edit it after the invocation.
5. Confirm the invocation
Wait until the configured time has passed. In the Lambda console:
- Open the function.
- Go to Monitor.
- Select View CloudWatch logs.
- Open the newly created log stream.
- Confirm that the configured event message appears in the output.
If the log group is unavailable immediately after function creation, that does not necessarily indicate a failure. The logging resources may not exist until Lambda has been invoked.
6. Clean up
After completing the exercise, delete the EventBridge schedule and the Lambda function if they are no longer needed. Also review any role created specifically for the exercise and remove unused resources according to your normal cleanup process.
Exam- or Assessment-Relevant Takeaways
For AWS Certified CloudOps Engineer Associate preparation, this workflow reinforces scenario recognition rather than memorization of a particular console sequence:
- Use an EventBridge schedule when a target must be invoked at a configured time.
- A Lambda function can be used as the scheduled target.
- The schedule can pass a JSON input payload to Lambda.
- The schedule requires permission to invoke the target; the console can create a role for this purpose.
- Lambda execution permissions are separate from the schedule’s target-invocation permissions.
- CloudWatch Logs are a practical verification point for a Lambda invocation.
- A missing log group before the first invocation is expected in this simple workflow.
- A one-time schedule must be configured with a future date and time; an already-passed time will not produce the intended demonstration.
- Flexible time windows affect how precisely the schedule runs. This exercise disables the window.
These points support tool selection and troubleshooting decisions, but the lesson does not define an official list of certification objectives.
Tool / Feature Decision Guide
| Requirement | Appropriate choice or setting | Reason |
|---|---|---|
| Invoke a service at a configured time | EventBridge schedule | Provides time-based invocation of a target. |
| Run custom code in response to the schedule | Lambda target | Accepts the scheduled event and processes it without managing a server. |
| Pass data to the function | JSON input payload | The configured event is delivered to Lambda as input. |
| Verify that the function ran | Lambda Monitor and CloudWatch Logs | The function prints the received event, making execution observable. |
| Avoid intentionally allowing a flexible execution window | Disable flexible time window | Keeps the exercise focused on the configured schedule time. |
| Keep a completed one-time schedule available for inspection | Set post-completion action to none | Prevents automatic deletion after completion. |
| Allow EventBridge to invoke Lambda | Create or select an invocation role | The scheduling service needs permission to call the target. |
| Avoid retaining demonstration resources | Delete the schedule and function after testing | Removes resources that are no longer required. |
Common Traps / Misconceptions
- Confusing the Lambda execution role with the EventBridge invocation role: Lambda’s role controls what the function can do, such as write to CloudWatch Logs. The schedule also needs permission to invoke Lambda.
- Using a time that is not in the future: A schedule created after its selected time may not run as expected. Choose a time several minutes ahead and update it if setup takes longer than planned.
- Breaking the payload JSON: Change the message value without removing quotation marks or otherwise invalidating the JSON structure.
- Expecting logs before the first invocation: The relevant log group or stream may be created only after Lambda runs.
- Treating a missing log group as proof of a failed schedule: First confirm whether the scheduled time has passed and whether the function has been invoked.
- Forgetting the time zone: The displayed schedule time is interpreted using the selected time zone, so an incorrect choice can make the invocation appear late or missing.
- Assuming the schedule is automatically removed: The exercise explicitly sets the post-completion action to none. Delete the schedule manually when it is no longer needed.
- Editing the wrong resource: If the schedule needs to run again, update its date and time rather than creating unnecessary duplicate resources.
Real-World Engineer / Analyst Notes
- Use descriptive names for schedules and functions so their relationship is clear during operations and troubleshooting.
- When investigating a missed invocation, check the configured date, time zone, and flexible time window before changing Lambda code.
- Verify the target function and input payload in the schedule configuration. A successful schedule invocation with an unexpected message can indicate a payload problem rather than a Lambda runtime problem.
- Inspect CloudWatch Logs only after allowing enough time for the scheduled invocation and log stream creation.
- Keep the schedule’s invocation role and Lambda’s execution role conceptually separate when reviewing permissions.
- One-time schedules are useful for demonstrations and delayed actions, while a recurring requirement would need an appropriate recurring schedule configuration; this lesson does not demonstrate a recurring expression.
- Clean up temporary schedules, functions, and exercise-specific roles to avoid retaining unnecessary operational resources.
Quick Reference Summary
- Source: EventBridge schedule.
- Target: AWS Lambda function.
- Input: Valid JSON payload.
- Lambda behavior: Prints the received event.
- Verification: Lambda Monitor → View CloudWatch logs.
- Schedule timing: Choose a future date and time and the correct time zone.
- Flexible time window: Disabled in the exercise.
- Permissions: Lambda needs CloudWatch Logs permissions; the schedule needs permission to invoke Lambda.
- Completion behavior: Set to none to retain the schedule.
- Cleanup: Delete the schedule and Lambda function when finished.
Flashcards
Q: A workload must invoke a Lambda function at a configured future time. Which AWS feature should you select?
A: Use an Amazon EventBridge schedule with the Lambda function as its target. The schedule provides time-based invocation without requiring a continuously running host.
Q: What is the purpose of the JSON input configured on an EventBridge schedule?
A: It supplies the event data delivered to the target Lambda function. The function in this exercise prints that received event to CloudWatch Logs.
Q: Which role permissions allow the Lambda function in this exercise to write its output to CloudWatch Logs?
A: The Lambda execution role must include permission to write to CloudWatch Logs. This is distinct from the role EventBridge uses to invoke the function.
Q: EventBridge is configured to invoke Lambda, but the Lambda function cannot be invoked by the schedule. Which permission area should be checked first?
A: Check the schedule’s target-invocation role and its permission to invoke the selected Lambda function. The Lambda execution role controls actions performed after the function starts.
Q: Why should a one-time EventBridge schedule be assigned a time several minutes in the future?
A: The schedule must have a future execution time when it is created, and the setup process needs time to finish. If the selected time passes, update the schedule before expecting an invocation.
Q: What is the operational effect of disabling the flexible time window in this exercise?
A: It avoids intentionally allowing the scheduler a flexible execution window. The demonstration therefore focuses on the configured schedule time.
Q: The Lambda console shows no CloudWatch log group immediately after the function is created. What is the likely explanation?
A: The function may not have run yet. The log group or stream can appear after the first scheduled invocation.
Q: Where should you verify that the scheduled Lambda invocation processed the expected payload?
A: Open the Lambda function’s Monitor view, choose View CloudWatch logs, and inspect the log stream created by the invocation.
Q: When would you set the schedule’s post-completion action to none?
A: Set it to none when the schedule should remain available after its one-time execution for inspection or editing. It must then be deleted manually when no longer required.
Q: What is the trap when modifying the sample EventBridge payload?
A: The message can be changed, but the resulting input must remain valid JSON. Editing outside the quoted value can break the payload structure.
Q: How do the Lambda execution role and the EventBridge invocation role differ?
A: The Lambda execution role grants the running function permissions such as CloudWatch Logs access. The EventBridge role grants the scheduling service permission to invoke the Lambda target.
Q: The schedule ran, but the function logged an unexpected message. Which configuration should be reviewed?
A: Review the schedule’s JSON input payload and confirm that the correct Lambda function is selected. The schedule controls the event data passed to the function.
Practice Questions
Question 1
An operator creates a one-time EventBridge schedule for 14:00, but setup takes until 14:05. The Lambda function has not produced any logs. What is the best next action?
A. Change the Lambda runtime to a newer Python version.
B. Add CloudWatch Logs permissions to the EventBridge schedule.
C. Update the schedule to a new time in the future.
D. Delete the Lambda execution role.
Correct answer: C. The schedule time must be in the future when configured for this exercise. Updating it to a future time allows the invocation to occur.
Question 2
A scheduled Lambda invocation succeeds, but the engineer cannot find a log group before the first run. What is the most likely explanation?
A. EventBridge schedules cannot invoke Lambda.
B. CloudWatch logging resources may not exist until Lambda is invoked.
C. The schedule must use a recurring expression.
D. The payload must be stored in Amazon S3 first.
Correct answer: B. The exercise expects the log group or stream to become available after the Lambda function executes.
Question 3
A team wants EventBridge to invoke a Lambda function and pass { "message": "daily check" }. Which configuration best matches the lesson’s workflow?
A. Select Lambda as the target and provide the object as valid JSON input.
B. Put the object in the Lambda execution role policy.
C. Add the object to the CloudWatch Logs log group name.
D. Select CloudWatch Logs as the target and omit Lambda input.
Correct answer: A. The schedule’s input payload is delivered to the selected Lambda target, and valid JSON must be preserved.
Question 4
A function’s code runs successfully when tested manually, but a schedule cannot invoke it. Which distinction is most important when troubleshooting?
A. The Lambda execution role and the EventBridge target-invocation role serve different purposes.
B. CloudWatch Logs must be disabled for scheduled invocations.
C. The Lambda payload must always be plain text.
D. The schedule must use the default time zone.
Correct answer: A. Manual execution can work with a valid Lambda execution role while scheduled invocation still fails if EventBridge lacks permission to call the function.
WordPress Metadata
Suggested Slug:
aws-eventbridge-scheduled-lambda-invocation
Meta Description:
Learn how to configure an Amazon EventBridge schedule that invokes a Lambda function with a JSON payload and verifies execution through CloudWatch Logs.
Tags:
AWS, Amazon EventBridge, EventBridge Scheduler, AWS Lambda, CloudWatch Logs, Cloud automation, Scheduled tasks, Serverless, SOA-C03