ExerciseTopic: Lambda and API Gateway: inputs, testing and failure investigation
Lambda test event lab: distinguish inputs, returns, logs and timeouts
Accepting an invocation and completing the intended function work are separate. Change fixed conditions to compare synchronous 200 with a function error, a timeout, and asynchronous 202 with an unobserved result. No real AWS or user code is executed.
Separate event JSON, caller response, function return and logs; explain what a condition change establishes and what remains unverified.
Know the roles of a Lambda event and handler. No AWS account or real logs are needed. No functions are created/invoked or reconfigured.
Conditions you change and assumptions you retain
The opening example invokes synchronously but the fixed handler returns an error. Compare the caller API response with the function result. Both are modeled examples from supplied conditions, not records of real traffic.
Change conditions and inspect the result stage
All data is fixed and synthetic. No AWS invocation, real-log retrieval, input storage or input transmission occurs. Duration is stipulated.
1. Choose conditions
Inspect event JSON and the supported function type
Selected event JSON (fixed example)
{}The opening fixed result is below. JavaScript enables the controls.
2. Read the result stage
Conditions changed. The result below belongs to the previous conditions. Evaluate again.
Input 1 / evaluated 1The fixed handler returns an error
Caller API response example
200: modeled synchronous invocation
Function result
Fixed function error
The fixed fail preset returns an error. Read it separately from the API 200.
Return/error example
{
"errorType": "SyntheticExampleError"
}Log example (synthetic)
MODEL_FIXED_HANDLER_THROW · 1s
Async retry plan
No async retry plan is shown under these conditions.
Zero retries does not guarantee exactly-once processing.
Inspect model scope and reasoning
- Model
- lambda-fixed-1
- Reason code
- L22_FUNCTION_ERROR
- Not verified
- Real permissions, duration, invocation count, log arrival, networking or memory performance
Separate the input, return and log
- Test event → Fixed handlerJSON input
- Fixed handler → Function returnReturn/error
- Fixed handler → Example logSynthetic log
- Test event
- Choose a fixed JSON input.
- Fixed handler
- Model only the specified preset.
- Function return
- Result or error for the caller.
- Example log
- A separate synthetic record.
{
"length": 6,
"width": 7
}The area preset multiplies these values when both are numbers in 0–100, returning {"area": 42}. The separate MODEL_FIXED_HANDLER_RETURN log example is synthetic. It is neither retrieved from AWS nor a built-in AWS handler.
Compare fixed conditions by result stage
| Condition | Modeled API response | Function result |
|---|---|---|
| Sync fail; 3-s deadline/1-s duration | 200 | Fixed function error |
| Sync slow; 3-s deadline/8-s duration | 200 | Timeout |
| Sync slow; 10-s deadline/8-s duration | 200 | Fixed work completed |
| Sync slow; duration unknown | Assume 200 | Deadline comparison unknown |
| Async; configure 0–2 retries | Assume 202 | Execution after acceptance not observed |
Async retries and why results remain unverified
The 0–2 retry setting concerns asynchronous function errors. It describes retries planned after the initial execution. Throttling/system errors and event source mappings such as SQS follow other conditions.
Managed Instances and event source mappings are outside this evaluator. It does not impose the ordinary 900-s limit on other execution modes or invent fast/slow outcomes when duration is unknown.
Check what the result establishes
Choose an option to see the result and explanation.
Choose an option to see the result and explanation.
Choose an option to see the result and explanation.
Choose an option to see the result and explanation.
Choose an option to see the result and explanation.
Choose an option to see the result and explanation.
Check, then explain in your own words
- Read the initial 200 and function error separately.
- Change the slow preset deadline from 3s to 10s and evaluate again.
- Compare async retry 0/2 and explain what is unobserved.
Check your understanding: An async invocation returns 202 with zero retries. Does that prove success and exactly-once processing?
No. Check acceptance, function execution and possible duplicates separately.
202 does not establish completion, and the retry setting alone does not rule out duplicate delivery.
Sources and conditions checked
The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.
Scope and conditionsConsole JSON test events invoke synchronously. The area/hello/slow/fail handlers are fixed site examples, not built-in AWS operations.
Used in this lessonSeparate the input, return and log
Scope and conditionsDistinguish 200 for RequestResponse from 202 for Event. Status codes do not replace function-error inspection. The model assumes acceptance/permissions and sends no API request.
Used in this lessonConditions you change and assumptions you retain Compare fixed conditions by result stage
Scope and conditionsSeparate synchronous return values, function errors/logs and caller connection deadlines. Synthetic logs are neither retrieved logs nor a complete runtime log format.
Used in this lessonConditions you change and assumptions you retain Separate the input, return and log
Scope and conditionsThe ordinary function deadline is 1–900s; special Managed Instances modes are outside this model. Duration is stipulated, not inferred from memory. Deadline equality follows a local teaching rule.
Used in this lessonCompare fixed conditions by result stage Async retries and why results remain unverified
Scope and conditionsRetry ownership and conditions depend on invocation method/error type. Direct synchronous function errors are not automatically retried by Lambda; stream/queue mappings have distinct rules.
Used in this lessonAsync retries and why results remain unverified
Scope and conditionsDistinguish the default two additional function-error attempts from throttling/system-error handling. Duplicate delivery can occur even without function errors; 1+n is not a guaranteed actual count.
Used in this lessonAsync retries and why results remain unverified
Scope and conditionsMaximumRetryAttempts 0–2 configures function-error retries. Event age/discard/failure destinations are separate. Valid configuration does not prove execution success. No real setting is changed.
Used in this lessonCompare fixed conditions by result stage Async retries and why results remain unverified
Scope and conditionsReal log delivery requires execution-role permissions and may be delayed. Returns and logs differ; fixed synthetic log examples do not establish actual log arrival.
Used in this lessonSeparate the input, return and log