I want to troubleshoot AWS Lambda functions that fail after "unexpected runtime version update" errors, or that don't work because of a runtime version change.
Short description
The default Lambda runtime update mode automatically updates your function to the most recent and secure runtime version. If a new runtime version is incompatible with your existing function, then you receive the "unexpected runtime version update" error.
To resolve this issue, check whether the termination occurs at the same time as an automatic runtime update. For more information, see Identifying Lambda runtime version changes.
If the termination occurs with the automatic runtime update, then determine the last version that your function successfully used. Use Lambda runtime management controls to manually update the runtime version used by your function.
Note: Auto updates are turned on by default. It's a best practice to receive the latest runtime version update.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.
Use the Lambda console to identify and update your runtime version
Complete the following steps:
-
Open the Lambda console and navigate to the Functions page.
-
Choose Monitor, and then choose View CloudWatch Logs.
-
Select the Lambda function CloudWatch log stream that has the successful invocation.
-
Copy the runtime ARN that is used in the INIT_START log line, as shown in the following example:
INIT_START Runtime Version: python:3.9.v14 Runtime Version ARN: arn:aws:lambda:eu-south-1::runtime:7b620fc2e66107a1046b140b9d320295811af3ad5d4c6a011fad1fa65127e9e6I
-
Return to the Functions page.
-
On the Code tab, under Runtime settings, choose Edit runtime management configuration.
-
Under Runtime management configuration, choose Manual.
-
Enter the runtime version ARN that you copied in step 4.
-
Choose Save.
Use the AWS CLI to revert your runtime configuration to the previous version
To revert your runtime management configuration to the previous version, run the put-runtime-management-config AWS CLI command. Make sure that you're using the manual runtime update mode. Replace the ARN with your runtime version ARN:
aws lambda put-runtime-management-config --function-name arn:aws:lambda:eu-west-1:069549076217:function:myfunction --update-runtime-on Manual --runtime-version-arn arn:aws:lambda:eu-west-1::runtime:8eeff65f6809a3ce81507fe733fe09b835899b99481ba22fd75b5a7338290ec1
The output looks similar to the following:
{
"UpdateRuntimeOn": "Manual",
"FunctionArn": "arn:aws:lambda:eu-west-1:069549076217:function:myfunction",
"RuntimeVersionArn": "arn:aws:lambda:eu-west-1::runtime:8eeff65f6809a3ce81507fe733fe09b835899b99481ba22fd75b5a7338290ec1"
}
Related information
Roll back a runtime version using Manual runtime update mode