The signature and its nearby causes#
The deploy succeeded: LastUpdateStatus is Successful, and the alias points at the new version. Then every invocation that reaches the new version fails, often before your handler logs anything. The failure happens during the init phase, when Lambda starts the runtime, loads your code and runs code outside the handler. Three causes share that signature:
- Packaging. The module the handler names, or something it imports, is not in the package or cannot load on this runtime.
- Handler setting. The package is fine, but the
Handlersetting names a file or function that does not exist in it, or a container image's entry point is wrong. - Init duration. The code loads, but initialization takes longer than Lambda allows.
Lambda execution environment lifecycle · Troubleshoot invocation issues
If the update itself failed instead, LastUpdateStatus is Failed and the old code is still running; see the reason code guide.
Read the error type#
Use a read-only profile and replace the uppercase placeholders. Lambda writes to /aws/lambda/FUNCTION_NAME by default. This Logs Insights query over the minutes after the deploy finds runtime error types and init reports. LoggingConfig
fields @timestamp, @logStream, @message
| filter @message like /Runtime\.|INIT_REPORT|Init Duration|Sandbox\.Timedout/
| sort @timestamp desc
| limit 50
| What the log or response shows | Step that failed | Most likely cause |
|---|---|---|
Runtime.ImportModuleError, with Unable to import module (Python) or Cannot find module (Node.js) | Loading the handler's module | Packaging, or a handler setting that names a missing file |
| An error saying the handler function was not found or not exported | Finding the function in a module that loaded | Handler setting |
Runtime.InvalidEntrypoint | Starting a custom runtime or container image | No executable bootstrap at the package root, or a wrong image entry point |
An INIT_REPORT line with Status: timeout | Finishing init in time | Init duration |
Sandbox.Timedout with no init timeout in the same log stream | Running the handler | The function timeout or a slow dependency, not init |
Sandbox.Timedout alone does not place the timeout in init, because a handler that runs past the function timeout reports it too. Read it as an init failure only beside an INIT_REPORT timeout for the same environment. The import error names come from AWS's Knowledge Center articles for Python and Node.js. AWS's guides found for this page do not name an error type for a handler function that is missing from a module that loaded, so read the message for the function name. For Runtime.InvalidEntrypoint, the troubleshooting page describes a runtime that could not find a valid bootstrap in /var/task or /opt, and a separate Knowledge Center article covers a misconfigured entry point in a container image. Wording inside the messages varies by runtime, so key on the error type. Python import errors · Node.js import errors · InvalidEntrypoint in images
Compare the two versions' settings#
An import error can come from either a broken package or a handler that points at the wrong file, and the error type alone does not say which. Compare the configuration of the version that worked with the one that fails. FunctionConfiguration
for v in PREVIOUS_VERSION NEW_VERSION; do
aws lambda get-function-configuration \
--profile PROFILE --region REGION --function-name FUNCTION_NAME --qualifier "$v" \
--query '{version:Version,handler:Handler,runtime:Runtime,package:PackageType,sha:CodeSha256,size:CodeSize,layers:Layers[].Arn,timeout:Timeout,memory:MemorySize,architectures:Architectures,image:ImageConfigResponse.ImageConfig}' \
--output json --no-cli-pager
done
| What differs between the versions | Reading |
|---|---|
handler | The handler setting changed. Check the new value against the file and function names in the package; each runtime has its own convention, such as filename.methodname |
sha and size only | The package changed under the same settings. List the new package's contents and compare its layout and dependencies with the old one |
runtime, layers or architectures | The package may be fine but built for another runtime version or CPU architecture, or it relied on a layer that is gone |
image (entry point, command, working directory) | A container image override changed |
Nothing but sha and init now takes longer | Read init duration next |
The code in a package must be compatible with the function's instruction set architecture, x86_64 or arm64. Handler naming · UpdateFunctionCode
When init runs out of time#
The init phase is limited to 10 seconds. If the runtime and extensions are not ready within that time, Lambda retries init at the first invocation, this time with the function's configured timeout, and AWS recommends against depending on that retry. A timeout appears in the log as an INIT_REPORT line, in AWS's example INIT_REPORT Init Duration: 1236.04 ms Phase: init Status: timeout. Execution environment lifecycle
So an init timeout after a deploy points at one of two changes: the new code does more work at startup, such as loading a larger library or opening connections, or the function's Timeout is too short for init and the handler together on that retry. AWS's troubleshooting page suggests raising the function timeout so that both phases fit. That helps only if init finishes within the new timeout; if the release added startup work, reduce it, then read Init Duration on the next cold start. Troubleshoot invocation issues
The operator guide notes that the 10-second limit does not apply to functions using provisioned concurrency, SnapStart or Lambda Managed Instances. For Lambda Managed Instances, AWS documents init failures as LastUpdateStatusReasonCode values that begin with FunctionError., reported on the update rather than on an invocation. Static initialization · Managed Instances troubleshooting
An illustrative example: two failed releases#
These records are fictional. The function checkout-api runs Python on version 57, and the alias live moves to version 58 at 14:00.
In the first release, every invocation of version 58 returns Runtime.ImportModuleError with No module named 'stripe_client'. Comparing versions 57 and 58 shows the same Handler, Runtime and Layers, a new CodeSha256, and a CodeSize 3 MB smaller. The build step that vendored dependencies into the package was skipped. Rebuild the package; the handler setting is fine.
In the second release, the error says the handler function was not found. The comparison shows Handler changed from app.handler to app.checkout in the infrastructure template, while app.py still defines its entry function as handler. The module loaded; the function name is wrong. The package is fine. Set Handler back to app.handler, or rename the function to match.
Where the error type stops helping#
- Init runs when Lambda creates an execution environment. With a weighted alias or a canary, only the share of traffic routed to the new version fails, so the error rate looks smaller than the defect. In CloudWatch, the
ExecutedVersiondimension separates error rates for the two versions behind a weighted alias. Viewing Lambda metrics - The
Errorsmetric counts runtime errors, such as timeouts and configuration errors, together with exceptions your code throws, so a rise inErrorsalone does not separate an init failure from a handler bug. The log does. Lambda metric types
For the matching fields in other AWS deployment services, see the signature table. If the deployment used CodeDeploy traffic shifting, an alarm on these errors can roll it back; the canary rollback guide shows how to tell the alarm from a traffic hook.
Questions#
What does Runtime.ImportModuleError mean in Lambda?
The runtime could not load the module your handler names or something that module imports. Check that the package contains the module and its dependencies at the expected path, and that the handler setting names the right file.
How do I tell a packaging error from a wrong handler setting?
Compare Handler, Runtime, Layers and CodeSha256 between the version that worked and the one that fails. If only the package hash changed, the package is the suspect; if Handler changed, check it against the files in the package.
How long can Lambda initialization take?
The init phase is limited to 10 seconds. If it does not finish, Lambda retries init at the first invocation within the function's configured timeout. The 10-second limit does not apply with provisioned concurrency, SnapStart or Lambda Managed Instances.