DEV Community

Roman Dubrovin
Roman Dubrovin

Posted on

AWS Deprecates Python 3.10 for Lambda: Migrate to Python 3.12+ for Continued Support and Security

AWS Deprecates Python 3.10 for Lambda: The Urgent Need to Migrate to Python 3.12+

If you’re running Python 3.10 on AWS Lambda, mark your calendar: October 31, 2026 is the deprecation deadline. After this date, your Lambda functions will continue to run, but they’ll lose critical security patches, become uneditable via the console, and face creation and update blocks by July 29, 2027 and August 31, 2027, respectively. This isn’t just a nudge—it’s a hard stop that jeopardizes application stability and security. The clock is ticking, and migrating to Python 3.12+ isn’t optional; it’s mandatory.

Why Python 3.10 is Being Deprecated: The Technical Underpinnings

AWS’s decision to deprecate Python 3.10 aligns with Python’s own end-of-life (EOL) timeline and AWS’s push for modern, secure standards. Python 3.10 reached EOL in October 2023, meaning no more security patches or updates. AWS can’t sustain runtimes for versions Python no longer supports. Here’s the causal chain: EOL → no upstream patches → AWS drops support → security risks for users. It’s a mechanical process driven by dependency chains, not a whim.

The Real Work: Migrating to Python 3.12+

Upgrading from Python 3.10 to 3.12+ isn’t just a version bump—it’s a structural overhaul. Here’s what breaks and why:

  • distutils Removal (Python 3.12): distutils, a legacy package management tool, is gone in 3.12. Any code importing it—old setup.py scripts, outdated libraries—will fail. Mechanism: Python 3.12’s interpreter no longer recognizes the distutils module, triggering ModuleNotFoundError. Solution: Replace distutils with setuptools or packaging. Rule: If X uses distutils → use setuptools/packaging.
  • Removed Modules in 3.13 (PEP 594): cgi, crypt, and telnetlib are deprecated in 3.13. Mechanism: These modules are flagged for removal to reduce Python’s maintenance burden. Code relying on them will fail at runtime. Solution: Rewrite or find alternatives. Rule: If X uses cgi/crypt/telnetlib → refactor or replace.
  • OS Shift: Amazon Linux 2023: Python 3.12+ on Lambda runs on Amazon Linux 2023, not AL2. Mechanism: Compiled wheels and layers (e.g., numpy, psycopg2, cryptography) built for AL2 are incompatible with AL2023’s glibc version. Observable effect: ImportError or segmentation faults. Solution: Rebuild wheels/layers for AL2023. Rule: If X uses compiled dependencies → rebuild for AL2023.

Edge Cases and Common Pitfalls

Not all migrations are smooth. Here are edge cases and typical errors:

  • Python 3.11 as a Stopgap: Python 3.11 is still on AL2 and deprecated on June 30, 2027. It’s a short-term fix, not a solution. Mechanism: 3.11 buys time but inherits AL2’s eventual EOL. Optimal choice: Skip 3.11 and go straight to 3.12+. Rule: If X needs immediate migration → use 3.12+, not 3.11.
  • Hidden Dependencies: Libraries with indirect distutils dependencies (e.g., scikit-learn < 1.3) will fail. Mechanism: Transitive dependencies pull in distutils, breaking the import chain. Solution: Pin or update dependencies. Rule: If X has transitive distutils → update dependencies.

Practical Migration Steps

To identify affected functions, use this AWS CLI command:

aws lambda list-functions --function-version ALL --query "Functions[?Runtime=='python3.10'].FunctionName,Version" --output text
Enter fullscreen mode Exit fullscreen mode

For a detailed migration guide and AWS source links, check the free AWS end-of-support tracker.

Conclusion: Act Now, Avoid Chaos

The deprecation of Python 3.10 isn’t just a technical footnote—it’s a hard deadline with real consequences. Migrating to Python 3.12+ requires addressing removed modules, OS changes, and dependency updates. Procrastination risks security breaches, operational disruptions, and last-minute scrambles. Rule of thumb: If X runs on Python 3.10 → migrate to 3.12+ before October 2026. The mechanism is clear: AWS drops support → functions become vulnerable → applications fail. Don’t let your Lambda functions become collateral damage.

Impact Analysis: AWS Deprecates Python 3.10 for Lambda

AWS’s deprecation of Python 3.10 for Lambda functions isn’t just a calendar event—it’s a mechanical trigger for a cascade of failures. Here’s the breakdown of what breaks, why it breaks, and how it impacts your operations.

1. Loss of Security Patches: The Silent Decay

Starting October 31, 2026, Python 3.10 Lambda functions stop receiving security patches. This isn’t a theoretical risk—it’s a physical process of vulnerability accumulation. Without upstream patches from Python’s maintainers, every unaddressed CVE (Common Vulnerabilities and Exposures) becomes a permanent crack in your runtime. Attackers exploit these cracks through mechanisms like buffer overflows, injection attacks, or privilege escalations. The causal chain is clear: No patches → Unpatched CVEs → Exploitable vulnerabilities → Compromised functions.

2. Console Edit Block: The Operational Handcuff

Post-deprecation, the AWS console disables edits for Python 3.10 functions. This isn’t just an inconvenience—it’s a mechanical block in your CI/CD pipeline. The console’s backend API rejects PUT requests for these functions, returning a 400 Bad Request with a deprecation error. The impact? Hotfixes delayed → Incident resolution slowed → Operational downtime.

3. Creation/Update Blocks: The Hard Stop

By July 29, 2027, AWS blocks creation of new Python 3.10 functions. On August 31, 2027, updates to existing ones are blocked. This is a physical gate implemented in AWS’s Lambda control plane. The API endpoint for function creation/update (CreateFunction/UpdateFunctionConfiguration) returns a 403 Forbidden for Python 3.10. The causal chain: API block → Deployment pipeline halted → Application stagnation.

4. Technical Breakages in Python 3.12+: The Hidden Landmines

a. distutils Removal: The Dependency Domino

Python 3.12 removes distutils, replaced by setuptools or packaging. Any code importing distutils fails with a ModuleNotFoundError. The mechanism: Python’s interpreter no longer includes the distutils module in its standard library. The impact: Legacy setup.py scripts break → Build processes fail → Deployment blocked. Solution: Replace distutils with setuptools or refactor build scripts.

b. Removed Modules (cgi, crypt, telnetlib): The Dead Batteries

Python 3.13 removes these modules per PEP 594. Code importing them fails at runtime with a ModuleNotFoundError. The mechanism: Python’s interpreter explicitly excludes these modules. The impact: Legacy code relying on these modules crashes → Functionality loss. Solution: Refactor to use modern alternatives (e.g., hashlib instead of crypt).

c. OS Shift to Amazon Linux 2023: The Binary Incompatibility

Python 3.12+ on Lambda runs on Amazon Linux 2023 (AL2023), not AL2. Compiled wheels/layers (e.g., numpy, psycopg2) built for AL2’s glibc version fail on AL2023. The mechanism: AL2023 uses a newer glibc, causing symbol resolution errors or segmentation faults. The impact: Compiled extensions break → Functions crash at runtime. Solution: Rebuild wheels/layers for AL2023.

5. Edge Cases: Python 3.11 as a Temporary Crutch

Python 3.11 is deprecated on June 30, 2027, and remains on AL2. It’s a short-lived stopgap. The optimal choice is migrating directly to 3.12+ because:

  • 3.11’s AL2 compatibility is temporary. You’ll face the same OS shift later.
  • 3.12+ aligns with Python’s long-term support (LTS) strategy. It avoids double migrations.

Rule of thumb: If using Python 3.10 → migrate directly to 3.12+ before October 2026.

6. Hidden Dependencies: The Transitive Trap

Libraries with transitive distutils dependencies (e.g., scikit-learn < 1.3) break in Python 3.12+. The mechanism: These libraries import distutils internally, triggering a ModuleNotFoundError. The impact: Seemingly unrelated libraries fail → Deployment blocked. Solution: Update dependencies or pin versions compatible with setuptools.

Conclusion: The Optimal Migration Path

The deprecation isn’t just a deadline—it’s a technical cliff. The optimal solution is:

  • Migrate directly to Python 3.12+. It avoids the temporary fix of 3.11 and aligns with AWS’s long-term support.
  • Address distutils, removed modules, and OS changes. These are the primary failure points.
  • Rebuild compiled wheels/layers for AL2023. Binary compatibility is non-negotiable.

Failure to migrate by October 2026 results in: Security exposure → Operational paralysis → Application decay. The choice is mechanical: Migrate or break.

Migration Scenarios: Navigating the Python 3.10 to 3.12+ Transition on AWS Lambda

Migrating Python Lambda functions from 3.10 to 3.12+ isn’t just a version bump—it’s a technical overhaul. Below are six common scenarios developers face, dissected with causal explanations and optimal solutions. Each scenario highlights the mechanical process behind the breakage and the most effective fix.

1. distutils Removal in Python 3.12

Impact: Legacy setup.py scripts or libraries importing distutils fail with ModuleNotFoundError.

Mechanism: Python 3.12 drops distutils entirely, breaking any code that directly or transitively relies on it. The interpreter no longer recognizes the module, halting execution.

Solution: Replace distutils with setuptools or packaging. For transitive dependencies (e.g., scikit-learn < 1.3), update the library or pin to a compatible version. Rule: If distutils is detected in imports or dependencies, refactor to setuptools—it’s a drop-in replacement in most cases.

2. Removed Modules in Python 3.13 (PEP 594)

Impact: Code using cgi, crypt, or telnetlib crashes at runtime.

Mechanism: These modules are flagged for removal in Python 3.13, and their absence triggers NameError or ImportError exceptions. The interpreter cannot resolve the module names.

Solution: Refactor code to use modern alternatives. For example, replace crypt with hashlib for hashing. Rule: If legacy modules are in use, audit and replace them before migrating to 3.13. Ignoring this breaks runtime execution.

3. OS Shift to Amazon Linux 2023

Impact: Compiled wheels or layers (e.g., numpy, psycopg2) fail with ImportError or segmentation faults.

Mechanism: Python 3.12+ runs on Amazon Linux 2023, which uses a newer glibc version. Wheels compiled for Amazon Linux 2 (AL2) are incompatible due to binary differences in system libraries.

Solution: Rebuild wheels and layers specifically for Amazon Linux 2023. Use tools like docker to emulate the AL2023 environment for local compilation. Rule: If using compiled extensions, rebuild them for AL2023—AL2 binaries will not work. Skipping this step causes runtime failures.

4. Python 3.11 as a Temporary Stopgap

Impact: Migrating to Python 3.11 delays the inevitable, as it’s deprecated on June 30, 2027.

Mechanism: Python 3.11 remains on AL2, avoiding the OS shift issue, but its short support window makes it a suboptimal choice. It’s a temporary fix, not a long-term solution.

Solution: Migrate directly to Python 3.12+ to align with AWS’s long-term support (LTS) strategy. Rule: If time permits, skip 3.11—it’s a detour. Direct migration to 3.12+ avoids double effort and ensures compliance with AWS’s timeline.

5. Hidden Transitive Dependencies

Impact: Seemingly unrelated libraries fail due to transitive distutils dependencies.

Mechanism: Libraries like scikit-learn < 1.3 rely on distutils internally. When distutils is removed in 3.12, these libraries break, even if your code doesn’t directly import it.

Solution: Update or pin dependencies to versions compatible with setuptools. Use tools like pipdeptree to identify hidden dependencies. Rule: If a library fails post-migration, check its dependencies for distutils usage. Update or pin to fix.

6. Console Edit Block Post-Deprecation

Impact: Unable to edit Python 3.10 functions via the AWS console after October 31, 2026.

Mechanism: AWS disables console edits by rejecting API requests (400 Bad Request) for Python 3.10 functions. The backend API blocks modifications to deprecated runtimes.

Solution: Migrate to 3.12+ before the deadline to retain console edit functionality. For urgent hotfixes post-deprecation, use CLI or SDKs to update code. Rule: If console edits are critical, migrate before October 2026. Post-deprecation, rely on CLI/SDK for updates.

Optimal Migration Path

  • Direct Migration to 3.12+: Avoids temporary fixes and aligns with AWS LTS.
  • Address Key Breakages: Prioritize distutils, removed modules, and OS changes.
  • Rebuild Compiled Artifacts: Ensure wheels/layers are AL2023-compatible.

Professional Judgment: Migrating to Python 3.12+ is non-negotiable for security and operational continuity. Delaying risks unpatched vulnerabilities, console lockouts, and deployment halts. The optimal strategy is proactive migration, addressing technical debt before the October 2026 deadline.

Best Practices & Tools for Migrating Python 3.10 Lambda Functions to 3.12+

AWS’s deprecation of Python 3.10 for Lambda functions isn’t just a nudge—it’s a hard deadline with tangible consequences. By October 31, 2026, failing to migrate means losing security patches, console edit capabilities, and eventually, the ability to create or update functions. The transition to Python 3.12+ isn’t trivial, but with the right strategies and tools, it’s manageable. Here’s how to navigate the migration without breaking your production systems.

1. Identify Affected Functions: The First Domino

Before you can fix what’s broken, you need to know what’s broken. AWS doesn’t flag deprecated runtimes proactively, so you’re on your own. Use the following command to identify Python 3.10 Lambda functions per region:

Command:

aws lambda list-functions --function-version ALL --query "Functions[?Runtime=='python3.10'].FunctionName,Version" --output text

Mechanism: This CLI query filters all Lambda functions by runtime, returning the function name and version. It’s a direct API call to AWS’s Lambda service, bypassing the console’s lack of deprecation warnings.

2. Tackle the Python 3.12+ Breaking Changes: Where Things Actually Fail

a. distutils Removal: The Silent Killer

Impact: Python 3.12 drops distutils, causing ModuleNotFoundError in legacy setup.py scripts or libraries that import it directly or transitively.

Mechanism: The Python interpreter no longer recognizes distutils, breaking build processes that rely on it. Transitive dependencies (e.g., scikit-learn < 1.3) may fail silently, blocking deployments.

Solution: Replace distutils with setuptools or packaging. Use pipdeptree to identify hidden dependencies and update/pin them to compatible versions.

Rule: If your build pipeline uses setup.py or libraries pre-2022, assume distutils is a risk. Migrate to setuptools and audit dependencies with pipdeptree.

b. Removed Modules (cgi, crypt, telnetlib): The Dead Batteries

Impact: Python 3.13 removes these modules, causing NameError or ImportError at runtime.

Mechanism: PEP 594 flags these modules for removal, and Python 3.13 enforces it. Legacy code using these modules will crash immediately.

Solution: Replace crypt with hashlib, refactor cgi usage with modern web frameworks, and deprecate telnetlib entirely. Test replacements in isolation before deploying.

Rule: If your codebase predates 2010, assume these modules are present. Use static analysis tools like pylint to flag imports and refactor proactively.

c. OS Shift to Amazon Linux 2023: The Binary Incompatibility

Impact: Compiled wheels and layers (e.g., numpy, psycopg2) built for Amazon Linux 2 fail on AL2023 with ImportError or segmentation faults.

Mechanism: AL2023 uses a newer glibc version, making binaries compiled for AL2 incompatible. The Python interpreter attempts to load these binaries but fails due to missing symbols or ABI mismatches.

Solution: Rebuild wheels and layers for AL2023 using Docker containers. Example Dockerfile:

FROM public.ecr.aws/lambda/python:3.12RUN pip install numpy --platform manylinux2014_x86_64 --target /python
Enter fullscreen mode Exit fullscreen mode

Rule: If your Lambda uses compiled extensions, rebuild them for AL2023. Skip this step only if your dependencies are pure Python.

3. Testing Strategies: Catch Failures Before Production

Migration without testing is a gamble. Here’s how to de-risk it:

  • Unit Tests: Mock AWS Lambda context and test function logic in isolation. Focus on code paths using removed modules or compiled extensions.
  • Integration Tests: Deploy migrated functions to a staging environment with AL2023. Invoke them with sample events and verify responses.
  • Canary Deployments: Route 10% of production traffic to the migrated function. Monitor for errors using CloudWatch Alarms.

Mechanism: Testing catches failures at different layers—unit tests for code logic, integration tests for environment compatibility, and canary deployments for real-world behavior.

4. Automation Tools: Scale the Migration

Manual migration is error-prone and slow. Automate where possible:

  • AWS SAM CLI: Use SAM templates to define Lambda functions and dependencies. Automate builds and deployments with sam build and sam deploy.
  • CI/CD Pipelines: Integrate migration steps into your CI/CD pipeline. Example GitHub Actions workflow:
jobs: migrate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - run: pip install -r requirements-3.12.txt - run: sam build --use-container - run: sam deploy --resolve-s3
Enter fullscreen mode Exit fullscreen mode

Mechanism: Automation ensures consistency and repeatability. CI/CD pipelines enforce migration steps, reducing human error.

5. Edge Cases: What Could Still Break

Even with careful migration, edge cases lurk:

  • Transitive Dependencies: Libraries like scikit-learn < 1.3 rely on distutils. Update or pin these dependencies to avoid silent failures.
  • Custom Layers: Layers compiled for AL2 won’t work on AL2023. Rebuild them using Docker and the AL2023 base image.
  • Python 3.11 as a Stopgap: While Python 3.11 avoids the OS shift, it’s deprecated by June 30, 2027. Migrate directly to 3.12+ to avoid double migration.

Rule: If you encounter an edge case, document it and share it with your team. Edge cases are rare but catastrophic if overlooked.

Professional Judgment: Migrate Directly to 3.12+ Before October 2026

Python 3.11 is a temporary fix with a shorter lifespan. Migrating directly to 3.12+ aligns with AWS’s long-term support strategy, avoids the OS shift twice, and future-proofs your Lambda functions. Address distutils, removed modules, and OS changes as the primary failure points. Rebuild compiled wheels/layers for AL2023 to ensure binary compatibility. Failing to migrate proactively risks security exposure, operational paralysis, and application decay.

Mechanism: Direct migration to 3.12+ minimizes technical debt and maximizes compatibility with AWS’s roadmap. Temporary fixes introduce additional migration cycles, increasing risk and cost.

Conclusion & Resources

AWS’s deprecation of Python 3.10 for Lambda is a critical shift that demands immediate action. The October 31, 2026 deadline isn’t just a date—it’s the point where your functions stop receiving security patches, become uneditable via the console, and eventually face creation and update blocks. This isn’t a gradual fade-out; it’s a hard stop that risks exposing your applications to unpatched vulnerabilities and operational paralysis.

Migrating to Python 3.12+ isn’t just about compliance—it’s about future-proofing your codebase. The technical challenges are real: distutils is gone, Amazon Linux 2023 replaces AL2, and hidden dependencies like transitive distutils imports can break your builds. But the solutions are clear:

  • Replace distutils with setuptools or packaging. This isn’t optional—legacy setup.py scripts will fail without it.
  • Rebuild compiled wheels and layers for AL2023. If you skip this, extensions like numpy or psycopg2 will crash at runtime due to glibc incompatibility.
  • Audit dependencies with pipdeptree. Libraries like scikit-learn < 1.3 silently rely on distutils, and updating them is non-negotiable.

Python 3.11 is a trap. It’s deprecated by June 30, 2027, and still runs on AL2, meaning you’ll face the same OS shift twice. Migrate directly to 3.12+—it’s the only path that aligns with AWS’s long-term support strategy.

To identify affected functions, use this command per Region:

aws lambda list-functions --function-version ALL --query "Functions[?Runtime=='python3.10'].FunctionName,Version" --output text

For deeper insights and official resources, refer to:

Professional Judgment: Delaying migration is a gamble with security and operational stability. If you’re running Python 3.10, start migrating to 3.12+ now. Address distutils, OS changes, and dependencies as your top priorities. Rebuild compiled artifacts for AL2023, and automate testing to catch edge cases early. The deadline is firm, and the risks of ignoring it are catastrophic.

Top comments (0)