AWS Compute Blog

Announcing end of support for Python 2.7 in AWS Lambda

This post is written by Jonathan Tuliani, Principal Product Manager, AWS Lambda.

On July 15, 2021, AWS Lambda will deprecate Python 2.7 as a supported runtime, formally ending our Python 2.7 support.

Why are we ending support for Python 2.7 in Lambda?

Python 2.7.18 was the last release of Python 2. The Python Software Foundation (PSF), which is the Python language governing body, states that “As of January 1st, 2020 no new bug reports, fixes, or changes will be made to Python 2, and Python 2 is no longer supported.”

AWS Lambda previously announced continued support until June 1, 2020. As we enter 2021, many community projects are stopping their support for Python 2, and AWS will also end Python 2.7 support for the AWS CLI and SDK. AWS Lambda end of support for Python 2.7 is aligned with these changes.

What does ‘end of support’ mean for Lambda functions using Python 2.7?

As per the AWS Lambda runtime support policy, deprecation of a managed runtime happens in two phases. From the deprecation date of July 15, 2021, Lambda will no longer apply security patches and other updates to the Python 2.7 runtime used by Lambda functions. In addition, functions using Python 2.7 will no longer be eligible for technical support. You will no longer be able to create new Lambda functions using the Python 2.7 runtime from this date.

For an additional period of time, you can continue to update existing functions that use the deprecated runtime. For Python 2.7, this period will run until September 30, 2021. After this period, both function creation and updates will be disabled permanently. However, the function continues to be available to process invocation events.

These changes apply to all functions using the Python 2.7 managed runtime in AWS Lambda.

Will my existing Python 2.7 functions still run?

Yes, Python 2.7 functions will continue to run. However, AWS strongly recommends that you migrate functions to a supported runtime version so that you continue to receive security patches and remain eligible for technical support.

What about Python 2.7 functions deployed as container images?

You can continue to create and update Python 2.7 functions that are deployed as container images after the end of support date. However, Lambda will no longer update the Python 2.7 base image used to create these functions. You are responsible for managing security patches and other updates for your container images.

What do I need to do?

Migrate your existing Python 2.7 Lambda functions to a supported Python runtime. We recommend using Python 3.8, which is the latest supported Python version in Lambda. Workflows creating new functions should be updated by July 15, 2021, and existing functions updated by September 30, 2021.

As always, you should test your functions for Python 3 language compatibility before applying changes to your production applications.

How do I know if I have any functions using Python 2.7?

Customers with Python 2.7 functions will be notified by email and their Personal Health Dashboard. The following command shows how to use the AWS CLI to list all functions in a Region using Python 2.7:

aws lambda list-functions --function-version ALL --output text --query "Functions[?Runtime=='python2.7'].FunctionArn"

You can also use AWS Config advanced queries to list all functions using Python 2.7, and apply an Aggregator to extend the query scope to multiple accounts and supported Regions. Here’s an example AWS Config query:

AWS Config query scope

How do I upgrade to Python 3?

The Python community offers helpful guides and tools to help you port Python 2 code to Python 3. For more information, read:

What if I need additional help?

If you have any questions, contact us through AWS Support or the AWS Discussion Forums.