跳至內容

How do I upgrade my Lambda function runtime to the latest supported version?

2 分的閱讀內容
0

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

AWS 官方已更新 1 年前
1 評論

Recently, AWS is ending support for Python 3.9 in Lambda on December 15, 2025. Python 3.9 End-Of-Life (EOL) reached on October 30, 2025.

You can use the following script to identify these lambda functions in your account for any regions

#!/bin/bash

OLD_RUNTIME="python3.9"
NEW_RUNTIME="python3.12"

# Get a list of all enabled AWS regions
REGIONS=$(aws ec2 describe-regions --output text --query "Regions[].RegionName")

# For each region:
for REGION in $REGIONS; do
  echo "Processing region: $REGION"

  # List functions with the old runtime in the current region and extract FunctionNames
  aws lambda list-functions --region "$REGION" --output text \
    --query "Functions[?Runtime=='$OLD_RUNTIME'].FunctionName" | \
    grep -v '^$' | \
    xargs -I {} aws lambda update-function-configuration \
      --function-name {} \
      --runtime "$NEW_RUNTIME" \
      --region "$REGION"
done

echo "Upgrade process completed for all regions."

AWS
回答 5 個月前