{"id":2400,"library":"awslambdaric","title":"AWS Lambda Runtime Interface Client for Python","description":"The AWS Lambda Runtime Interface Client (RIC) for Python is a lightweight library that implements the Lambda Runtime API. It enables you to use alternative base images or build custom runtimes for your Python Lambda functions, making them compatible with the Lambda service. It manages the interaction between the Lambda execution environment and your function code, handling invocation events and responses. The library is actively maintained by AWS and is currently at version 4.0.0.","status":"active","version":"4.0.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-lambda-python-runtime-interface-client","tags":["aws","lambda","serverless","runtime","container","custom-runtime"],"install":[{"cmd":"pip install awslambdaric","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for JSON serialization/deserialization; historically had compatibility issues with specific Python versions which have since been addressed.","package":"simplejson","optional":false}],"imports":[{"note":"While awslambdaric itself is typically invoked by the Lambda runtime (e.g., via Dockerfile ENTRYPOINT), specific components like exception classes can be imported for custom runtime implementations or advanced error handling.","symbol":"LambdaRuntimeException","correct":"from awslambdaric.lambda_runtime_exception import LambdaRuntimeException"}],"quickstart":{"code":"# app.py\ndef handler(event, context):\n    print(f\"Received event: {event}\")\n    print(f\"Context: {context.aws_request_id}\")\n    return {\"statusCode\": 200, \"body\": \"Hello from Lambda!\"}\n\n# Dockerfile\nFROM python:3.9-slim-buster\n\n# Set working directory\nWORKDIR /var/task\n\n# Copy function code\nCOPY app.py .\n\n# Install awslambdaric and any other dependencies\nRUN pip install --no-cache-dir awslambdaric\n\n# Set the ENTRYPOINT to the AWS Lambda Runtime Interface Client\nENTRYPOINT [\"/usr/local/bin/python\", \"-m\", \"awslambdaric\"]\n\n# Set the CMD to your Lambda handler\nCMD [\"app.handler\"]","lang":"dockerfile","description":"This quickstart demonstrates how to create a Python Lambda function using a custom container image with `awslambdaric`. You define your Lambda handler in `app.py` and then create a `Dockerfile` that installs `awslambdaric` and sets it as the container's entrypoint, with your function handler as the command. This allows the Lambda service to properly invoke your Python code within the custom runtime environment."},"warnings":[{"fix":"Upgrade your Python runtime to 3.9 or newer (e.g., Python 3.13 support was added in v3.0.0) and ensure your `awslambdaric` dependency is compatible.","message":"Version 3.0.0 of `awslambdaric` dropped support for Python runtimes older than 3.9. Functions using Python versions 3.8 or earlier will no longer work with `awslambdaric` v3.0.0 and newer.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Plan to upgrade your Lambda functions to Python 3.10 or later versions. While `awslambdaric` itself supports Python 3.9+, the underlying Lambda service is deprecating the 3.9 runtime.","message":"AWS Lambda will deprecate Python 3.9 runtime. New functions using Python 3.9 will be blocked from creation after January 15, 2026, and existing functions cannot be updated with Python 3.9 after February 15, 2026.","severity":"deprecated","affected_versions":"All (affects Python 3.9 runtime environment)"},{"fix":"Adjust your packaging script or `Dockerfile` to install dependencies directly into the root of your function's deployment directory (e.g., `/var/task`) or ensure they are properly accessible on the `PYTHONPATH`.","message":"When upgrading Python runtime versions for Lambda functions (e.g., from 3.7 to 3.9), ensure that external dependencies are correctly packaged at the root level of your deployment, not within a 'packages' folder, as the underlying Python runtime search path changed.","severity":"gotcha","affected_versions":"All versions, specifically during Python runtime upgrades."},{"fix":"Ensure your Dockerfile correctly sets `ENTRYPOINT [\"/usr/local/bin/python\", \"-m\", \"awslambdaric\"]` and `CMD [\"your_module.your_handler_function\"]`.","message":"Incorrect configuration of `ENTRYPOINT` and `CMD` in Dockerfiles for custom runtimes is a common error. The `awslambdaric` module must be the `ENTRYPOINT`, and your function's handler path the `CMD`.","severity":"gotcha","affected_versions":"All versions when using container images."},{"fix":"`awslambdaric` versions 2.0.11 and newer (including 3.x and 4.x) have updated `simplejson` dependencies to be compatible with newer Python versions. Ensure you are using a recent `awslambdaric` version.","message":"Historical compatibility issues with the `simplejson` dependency (e.g., lack of Python 3.9 wheels for older `simplejson` versions) could lead to installation failures.","severity":"gotcha","affected_versions":"<=2.0.11 (addressed in 2.0.11 and later)"},{"fix":"Review the AWS Lambda documentation on SnapStart runtime hooks for Python to understand how to implement `after_restore` and `before_checkpoint` if your function uses SnapStart.","message":"Version 3.0.0 introduced support for SnapStart runtime hooks. If you are leveraging AWS Lambda SnapStart, be aware of the new hooks and how they might affect your function's initialization lifecycle.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}