Objectives
- Create a Lambda function
- Test a Lambda function
- Trigger a Lambda function from external event(s)
- Monitor and log function calls
- Remove a Lambda function
Lab Details
- Create an S3 bucket named images-YOUR_NAME.
- Create another S3 bucket named images-YOUR_NAME-resized.
- Upload this picture into the first bucket. You will use this file later when you manually invoke the Lambda function.
- Create a new Lambda function named
CreateThumbnail. The function definition can be found in this file. Change the Runtime to Python 3.14 and the Handler tolambda_function.lambda_handler. - Test your function. Create a test event using the Event template “Amazon S3 Put”. Replace
example-bucketwith the name of your image bucket (in both places). Change"key": "test/key"to"key": "brewers_logo.jpeg". Click Create and run the test. Verify that you now have a resized image in your resized S3 bucket.Take a screenshot of the thumbnail image in your S3 bucket.
- Add a Lambda trigger. Modify your
CreateThumbnailfunction by clicking Add Trigger. Set up an S3 trigger based on your S3 image bucket that fires for All object create events. - Verify that your Lambda trigger is working. Upload a new image into your images-YOUR_NAME bucket. After the upload completes, check your images-YOUR_NAME-resized bucket to confirm a thumbnail was created.
Take a screenshot of the new thumbnail image created by your Lambda trigger.
- After completing the lab and getting credit in the Grade Center, delete the Lambda and S3 resources to avoid being billed.
What did I learn?
- Create a bucket in Amazon S3
- Create a Lambda function
- Testing Lambda functions
- Lambda function triggers