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.Start with a scheduled report rather than an HTTP request. At 09:00, a scheduling service sends an event containing the report date. Lambda finds the configured handler, prepares an execution environment if necessary, and passes that event to the handler. Initialization runs before the handler's first invocation in that environment; later invocations may reuse initialized clients. Initialization is therefore a performance opportunity, not a promise that memory will survive tomorrow.
An invocation is one attempt to execute the function. A trigger is the service or integration initiating that attempt. The payload is the supplied event data. A synchronous requester waits for the attempt's response; asynchronous acceptance means AWS accepted work, not that the report exists. Distinguish malformed event data from an infrastructure invocation failure. Returning an error object may count as a normal function completion, whereas throwing an exception communicates failure through the relevant invocation mechanism and its retry rules.
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.