Python 3.11 EOL and Python 3.13 Adoption on AWS Lambda and Serverless — when and how should I migrate?
Python 3.11 on AWS Lambda runs on Amazon Linux 2, which reaches end of life on June 30, 2026. AWS recommends migrating to Amazon Linux 2023-based runtimes (Python 3.12, 3.13, or 3.14) before that date. Teams must choose a target Python version, understand AL2-to-AL2023 OS-level breaking changes, and verify third-party dependency compatibility — especially for Python 3.13 where 19 standard library modules were removed in PEP 594.
Blockers
- runtime/python-3.11 — EOL 2027-06-30, successor: runtime/python-3.13
- Lambda deprecation June 30, 2027; block-create July 31, 2027; block-update August 31, 2027; after AL2 EOL June 30, 2026 only critical and selected important security patches
- runtime/python-3.12 — EOL 2028-10-31, successor: runtime/python-3.13
- PEP 594 removed 19 standard library modules: cgi, cgitb, aifc, audioop, chunk, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib
- free-threaded CPython build (PEP 703) NOT available in AWS Lambda managed runtime; experimental JIT compiler also not enabled
- AL2023 uses microdnf/dnf instead of yum; glibc 2.34 (vs 2.26 in AL2)
Who this is for
- serverless
- low-ops
- cost-sensitive
- compliance
- enterprise
- small-team
Candidates
Migrate to Python 3.13 on AL2023 (recommended forward path)
As of 2026-03-16, Python 3.13 is available on AWS Lambda running on Amazon Linux 2023 (since November 14, 2024), with a Lambda deprecation date of June 30, 2029 — the longest available support window among current managed runtimes. On GCP Cloud Run Functions, Python 3.13 deprecates October 10, 2029.
When to choose
Best for serverless + low-ops or enterprise teams starting new Lambda projects, running greenfield rewrites, or willing to invest in a full dependency audit now to avoid a second migration before 2029. Choose this when your codebase does not use any of the 19 modules removed in PEP 594 (cgi, cgitb, aifc, audioop, chunk, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib) and your key dependencies — especially C-extension packages — publish Python 3.13 wheels.
Tradeoffs
Provides the longest Lambda support window (Lambda EOL June 30, 2027 for 3.11 vs June 30, 2029 for 3.13). AL2023 brings a smaller deployment footprint, updated glibc (2.34 vs 2.26 in AL2), and microdnf/dnf as the package manager replacing yum. Python 3.13 includes improved error messages with typo suggestions, PEP 667 defined locals() semantics, and PEP 696 TypeVar defaults. The tradeoff is the largest migration surface: PEP 594 removed 19 standard library modules deprecated since Python 3.11, and locals() mutation in optimized scopes no longer persists.
Cautions
The free-threaded CPython build (PEP 703, python3.13t) is NOT available in the AWS Lambda managed runtime — only the standard GIL-enabled build is deployed. The experimental JIT compiler is also not enabled. Verify all C-extension dependencies publish cp313 wheels on PyPI before migrating; packages like numpy have cp313 wheels but others may lag. Container image Dockerfiles using the python3.11 base image must switch from yum to dnf/microdnf when moving to the python3.13 AL2023 base image.
Migrate to Python 3.12 on AL2023 (conservative step-up)
As of 2026-03-16, Python 3.12 is available on AWS Lambda running on Amazon Linux 2023, with a Lambda deprecation date of October 31, 2028. On GCP Cloud Run Functions, Python 3.12 deprecates October 2, 2028. This is the smallest code-change migration from Python 3.11 that escapes the Amazon Linux 2 EOL on June 30, 2026.
When to choose
Best for serverless + enterprise or cost-sensitive + small-team teams that need to exit Amazon Linux 2 before June 30, 2026, but carry legacy dependencies or internal tooling that has not yet published Python 3.13 wheels. Choose this when you want to minimize code changes and dependency audit scope while still moving to AL2023 and gaining the glibc 2.34 and dnf package manager improvements.
Tradeoffs
Python 3.12 does not remove the 19 PEP 594 modules that Python 3.13 drops, so dependency compatibility risk is lower than a 3.13 migration. The AL2→AL2023 OS-level changes still apply: container image Dockerfiles must replace yum with dnf, and PEP 709 inlines comprehensions which changes locals() behavior inside them. Lambda deprecation is October 31, 2028 — about 14 months shorter than Python 3.13's June 2029 window, meaning a second migration may be needed sooner.
Cautions
Migrating to Python 3.12 does not eliminate the need to eventually move to 3.13 or later before 2029. If your team plans only one migration cycle, going directly to Python 3.13 avoids compounding migration costs. The AL2023 base image uses microdnf (symlinked as dnf) — any Lambda container images or build scripts that call yum must be updated regardless of whether you choose 3.12 or 3.13.
Stay on Python 3.11 past AL2 EOL with explicit risk acceptance
As of 2026-03-16, Python 3.11 on AWS Lambda has a Lambda deprecation date of June 30, 2027 (Block Create: July 31, 2027; Block Update: August 31, 2027). After the Amazon Linux 2 EOL on June 30, 2026, AWS will continue to apply only critical and selected important AL2 security patches to the Python 3.11 runtime until that Lambda deprecation date.
When to choose
Only appropriate for compliance + enterprise or cost-sensitive + small-team cases where migration is blocked by a specific, time-bounded constraint — such as a frozen audit window, a critical third-party dependency without Python 3.12/3.13 wheels, or a contractual freeze period — and you have an explicit remediation plan and stakeholder sign-off on the reduced post-June-2026 security posture.
Tradeoffs
Lambda functions continue to run and deploy without interruption through June 30, 2027. AWS will still apply critical AL2 security patches after the June 30, 2026 AL2 EOL. This avoids migration risk in the short term and allows more time for dependency ecosystem readiness. The hard limit is August 31, 2027, after which existing Python 3.11 Lambda functions cannot be updated at all.
Cautions
AWS explicitly states it recommends customers upgrade to AL2023-based runtimes as soon as possible. After June 30, 2026, the security patch coverage narrows to critical and selected important issues only — non-critical CVEs in AL2 or Python 3.11 will not be remediated. Do not treat this as a no-action path: the block-update deadline of August 31, 2027 is a hard stop. GCP Cloud Functions Python 3.11 deprecates October 24, 2027 and decommissions April 24, 2028 on a separate but similar timeline.
Try with your AI agent
$ npm install -g pocketlantern $ pocketlantern init # Restart Claude Code, Cursor, or your MCP client, then ask: # "Python 3.11 EOL and Python 3.13 Adoption on AWS Lambda and Serverless — when and how should I migrate?"