How do I troubleshoot Lambda function failures caused by runtime version errors?

3 minute read
0

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:

  1. Open the Lambda console and navigate to the Functions page.

  2. Choose Monitor, and then choose View CloudWatch Logs.

  3. Select the Lambda function CloudWatch log stream that has the successful invocation.

  4. 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
  5. Return to the Functions page.

  6. On the Code tab, under Runtime settings, choose Edit runtime management configuration.

  7. Under Runtime management configuration, choose Manual.

  8. Enter the runtime version ARN that you copied in step 4.

  9. 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

AWS OFFICIAL
AWS OFFICIALUpdated 14 days ago