aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.81k stars 819 forks source link

A Python Lambda runtime version #13733

Open imortkz opened 5 months ago

imortkz commented 5 months ago

Amplify CLI Version

12.11.1

Question

The latest Amplify version still generates v3.8 Python runtime, while it will be EOL soon:

We are ending support for Python 3.8 in Lambda on October 14, 2024. This follows Python 3.8 End-Of-Life (EOL) which is scheduled for October, 2024 [1].

As described in the Lambda runtime support policy [2], end of support for language runtimes in Lambda happens in several stages. Starting on October 14, 2024, Lambda will no longer apply security patches and other updates to the Python 3.8 runtime used by Lambda functions, and functions using Python 3.8 will no longer be eligible for technical support. Also, Python 3.8 will no longer be available in the AWS Console, although you can still create and update functions that use Python 3.8 via AWS CloudFormation, the AWS CLI, AWS SAM, or other tools. Starting February 28, 2025, you will no longer be able to create new Lambda functions using the Python 3.8 runtime. Starting March 31, 2025, you will no longer be able to update existing functions using the Python 3.8 runtime.

We recommend that you upgrade your existing Python 3.8 functions to the latest available Python runtime in Lambda before October 14, 2024.

I can manually update the CloudFormation for lambda function to use v3.10 runtime, but it still will create a v3.8 venv.

Is there any plans to upgrade a default Python runtime?

ykethan commented 5 months ago

Hey @imortkz, thank you for reaching, marking this as feature-request to upgrade the default python runtime. From https://github.com/aws-amplify/amplify-cli/blob/6340adbb6f02e139128c712719d8054d8fab5ad1/packages/amplify-python-function-runtime-provider/src/util/buildUtils.ts#L10

you should be able to update the runtime in the CloudFormation template and pip file present in the function to 3.10, then run amplify build function to build the function locally before pushing.

imortkz commented 5 months ago

It's supposed to work for new function only?

Tried that with already deployed Python lambda function, didn't work:

Pipfile.lock (a89a07) out of date, updating to (296d86)... Locking [packages] dependencies... Building requirements... Resolving dependencies... ✔ Success! Locking [dev-packages] dependencies... Updated Pipfile.lock (4575da8dd7dda667a455b5ea8c5b6bf1c2a8fde62a8d4b747ada6e2146296d86)! Installing dependencies from Pipfile.lock (296d86)... To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run. 🛑 Could not find a pipenv site-packages directory at /Users/username/.local/share/virtualenvs/function-yFQL_vgG/lib/python3.10/site-packages

Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

Session Identifier: e4c545fe-1701-4253-8053-da203153cc0f

I guess the problem is that virtualenv was already built for Python 3.8

Can you please recommend steps to migrate function from 3.8 to 3.10 properly?

ykethan commented 5 months ago

@imortkz the information is currently documented here: https://docs.amplify.aws/react/build-a-backend/functions/configure-options/#updating-the-runtime you will need to ensure the python version is installed locally as well for the push to build the function

softwareengineerprogrammer commented 4 months ago

@ykethan I am having the same issue, updating the runtime in the cloudformation template json does not appear to be sufficient for python. Can you point us to a guide specifically for python (and not node)?

hisham commented 4 months ago

+1. Just want to emphasize these dates for the amplify team:

Starting February 28, 2025, you will no longer be able to create new Lambda functions using the Python 3.8 runtime. Starting March 31, 2025, you will no longer be able to update existing functions using the Python 3.8 runtime.