AWS Certified Developer – Associate
Lambda invocation vs execution errors: DVA-C03 troubleshooting
The Lambda Developer Guide separates two kinds of problem. Invocation errors happen before your code runs, for example missing permissions, throttling, a missing bootstrap file or an Init phase timeout, and they use 400 and 500-series status codes. Execution errors come from your code and return 200 with an X-Amz-Function-Error header.
What goes wrong before the handler runs?
Lambda validates the request and checks scaling capacity before it sends the event to the function. A direct caller sees invocation errors in the response. The caller needs lambda:InvokeFunction, and another service or account needs a statement in the function's resource-based policy.
Sandbox.Timedout with Task timed out after 3.00 seconds can be an Init phase timeout. Lambda runs Init again when the next request arrives, which is called a suppressed init. With a short timeout that second Init can time out again, or leave too little time for the Invoke phase. The fixes are a longer timeout, more memory (which also gives more CPU) or less initialization work.
Runtime.InvalidEntrypoint with Couldn't find valid bootstrap(s) usually means the root of the deployment package has no executable file named bootstrap. For a provided.al2023 function deployed as a .zip file, bootstrap must be at the root of the archive, not in a directory.
How does concurrency cause or stop invocations?
If one function uses all available concurrency, other functions are throttled. Reserved concurrency divides the account's concurrency into pools: the function can always scale to its reserved amount and never beyond it.
A function that writes to the same S3 bucket that triggers it can invoke itself in a loop. The first step is to reduce its available concurrency to zero, which throttles all future invocations. Setting reserved concurrency to 0 does this, and the function processes no events until you remove the limit. Then fix the code path, for example by writing to a different prefix or suffix from the one the trigger matches.
Provisioned concurrency has its own symptoms. It cannot be configured on $LATEST, so a trigger that invokes $LATEST gets cold starts. A non-zero ProvisionedConcurrencySpilloverInvocations metric means all provisioned concurrency was in use. During alias routing, traffic is split by a probabilistic model, and AWS advises a higher provisioned concurrency setting while routing is active.
What goes wrong during execution?
To see which version ran, read the function's logs. The version that was invoked is always shown on the START log line. Invocations that name no version or alias go to $LATEST.
If logs or traces do not appear, the execution role needs AWSLambdaBasicExecutionRole for CloudWatch Logs and AWSXRayDaemonWriteAccess for X-Ray. After adding permissions, make a trivial update to the function's code or configuration. That replaces running instances, which still hold outdated credentials. Logs can take 5 to 10 minutes to show up.
If only some logs are missing, look at volume. When a function writes logs faster than Lambda can send them, Lambda drops logs so that the function is not slowed down. Expect this above 2 MB/s for a single log stream. With JSON formatted logs, Lambda tries to write a logsDropped event. CloudWatch Logs quotas such as the PutLogEvents throttle limit can also throttle logging.
Where the exam catches people
- Believing an error thrown by your code returns a 4xx or 5xx status: Lambda returns 200 with the
X-Amz-Function-Errorheader. The 400 and 500 series are for invocation errors. - Believing that attaching a logging policy fixes running environments at once: they keep outdated credentials until a trivial code or configuration update replaces them.
- Believing
bootstrapcan sit in a subdirectory of the .zip file: forprovided.al2023it must be an executable at the root. - Believing a looping function is stopped by changing retry settings: the documented step is to reduce concurrency to zero, which reserved concurrency of 0 does.
- Believing missing log lines always mean missing permissions: above about 2 MB/s on one log stream, Lambda drops logs.