Invocation and handler
Lambda runs a configured handler when an invocation arrives. The event is input data; the context describes the invocation. Synchronous callers wait for a response, while asynchronous callers receive acceptance before execution completes. The function should validate input before performing work and return a contract the caller understands. For example, a Python handler returns {"statusCode": 200, "body": "hello"} for an HTTP integration, but a direct invocation can return ordinary JSON.
A Python handler returns {"statusCode": 200, "body": "hello"} for an HTTP integration, but a direct invocation can return ordinary JSON.Knowing who waits for the result helps you choose response contracts, retries, error handling, and appropriate monitoring for each invocation path.
Do not assume every event has the same structure; API Gateway events and SQS batches need different parsing and error handling logic.