Skip to content

Test a Lambda Function Manually

0

Hi re:Post,

Thank you for your time and help!

This question is related to a previous post/question of mine named, "How to automate daily delete snapshots and automate daily copy snapshots between regions."

I have just completed the second step:

  1. "Create the Lambda function using the code above ..."

The Lambda function is named, "Lambda-Function-RDS-Snapshot-Management" and it has the provided Python code.

The next steps:

  1. Set up EventBridge Scheduler to trigger the Lambda function daily: --> Open the EventBridge console --> Create a new schedule --> Set the schedule pattern to run daily --> Select your Lambda function as the target

  2. Test the function with a small number of snapshots first to ensure it works as expected

Is there a way I could test the function on it's own, ie run manually, without setting up step "3) Set up EventBridge Scheduler..." ?

Thanks!

Best Regards,

Donald

Screenshots below: Enter image description here Enter image description here

asked a year ago330 views

2 Answers
1
Accepted Answer

Yes, you can definitely test your Lambda function manually before setting up the EventBridge scheduler. Here's how to do it:

  1. Sign in to the AWS Management Console and open the AWS Lambda console.

  2. On the Functions page, find and select your function named "Lambda-Function-RDS-Snapshot-Management".

  3. Once on your function's page, select the "Test" tab.

  4. Create a new test event with an empty JSON object {} since your function doesn't require any specific input parameters.

  5. Give your test event a name (optional).

  6. Click "Test" to execute the function.

When you run the test, Lambda will invoke your function synchronously with the test event you provided. You can then view the execution results, including any logs or output from your function.

Since your function is designed to delete the oldest snapshots and copy new ones between regions, I'd recommend modifying your code temporarily for testing to limit the number of snapshots it processes (maybe set NUM_SNAPSHOTS to 1 or 2 instead of 14) to ensure it works as expected before running it on all your snapshots.

After confirming the function works correctly through manual testing, you can proceed with setting up the EventBridge scheduler for automated daily execution.
Sources
Testing Lambda functions in the console - AWS Lambda
Deploy agentic systems on Amazon Bedrock with the CrewAI framework by using Terraform - AWS Prescriptive Guidance

answered a year ago

AWS
SUPPORT ENGINEER

reviewed a year ago

0

Sure you can as described by repost. You have to make sure the event JSON file describes he event correctly. Here's a screen shot from lambda console.

Enter image description here

EXPERT

answered a year ago

  • Hi Shajam! Thank you for your time and help! The screenshot you provided is helpful as it matches exactly what I see when I view the "Test" tab. I'm following the steps outlined by the AI bot response and named the event: "TestSLambdaSnapshotFunc"

    Regarding, "make sure the event JSON file describes the event correctly."
    Can you expand upon that please?

    Reading step 4) from the AI support bot, "Create a new test event with an empty JSON object {} since your function doesn't require any specific input parameters." So I will leave this alone?: { "key1": "value1", "key2": "value2", "key3": "value3" }

    Thanks! Best Regards, Donald

  • I reduced the NUM_SNAPSHOTS to "2" and only two db names for the function to use. When I clicked the "Test" I got:

    "Executing function: succeeded"

    Awesome. But there is no info in the logs link. "Log group does not exist The specific log group: /aws/lambda/Lambda-Function-RDS-Snapshot-Management does not exist in this account or region."

    Is that because I created the function in the Oregon region when I should have created it in the N. California region?

  • So I tested it and nothing happened. No snaps moved, no snaps deleted. Only got this output: "Executing function: succeeded " " Executing function: succeeded (logs ) Details { "statusCode": 200, "body": ""Hello from Lambda!"" } " and " START RequestId: 0cc60224-130d-4525-89d8-45056891e216 Version: $LATEST END RequestId: 0cc60224-130d-4525-89d8-45056891e216 REPORT RequestId: 0cc60224-130d-4525-89d8-45056891e216 Duration: 1.67 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 36 MB Init Duration: 81.65 ms " So what was the point of this test? What did it test? Best Regards, Donald

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.