Lambda Basics

Objectives

Create and test a Lambda Hello World (Node.js/Python), pass input parameters, and fine-tune configurations (memory, timeout, log).

image

Key Steps

  1. Create a Node.js function

    • Runtime: Node.js 18.x (example). image
    • Sample handler returns JSON { message: "hello" }. image
    • Test event with a name parameter, log the result in CloudWatch. image
  2. Create a Python function

    • Runtime: Python 3.12 (example).
    • Handler reads event["name"] and returns a customized response. image
  3. Parameterization & Common Errors

    • Read the event (query/body will be attached by API Gateway in a later step).
    • Catch missing key errors, return appropriate status codes. image
  4. Light Optimization

    • Adjust Memory and Timeout to balance cost/performance.
    • Set CloudWatch retention. image