I want to upgrade my AWS Lambda function runtime to the latest version.
Resolution
Before you upgrade your Lambda function, list all the functions that are running the runtime that you want to upgrade. Run the following list-functions AWS Command Line Interface (AWS CLI) command:
aws lambda list-functions --query "Functions[?Runtime=='python3.12'].FunctionArn"
Note: Replace python3.12 with your runtime. If you receive errors when you run AWS CLI commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
View each function's Amazon CloudWatch Logs to find the function's most recently used ARN. If the latest runtime version isn't compatible with your deployment package, then use the ARN to roll back to the most recent stable runtime version.
If you encounter issues, then back up the Lambda functions before you upgrade. For more information about disaster recovery best practices, see AWS Lambda - exporting functions.
To upgrade the Lambda runtime, navigate to the Runtime settings and set your runtime version. Also, set Runtime management configuration to Auto. This setting automatically upgrades the function to the latest runtime and uses the two-phase runtime version rollout.
After you upgrade the runtime, take the following actions:
- Verify that the existing code runs on the new runtime version. If you the function causes issues on the new runtime, then use the function ARN to roll back to the previous working version.
- Verify that all the dependencies and layers in the code are compatible with the new runtime version.
Note: The code that you update in the new runtime version must be backward compatible.
Related information
Changing the runtime
Introducing AWS Lambda runtime management controls
Understanding how Lambda manages runtime version updates