You can deploy your Lambda function code as a container image. AWS provides the following resources to help you build a container image for your Python function:
-
AWS base images for Lambda
These base images are preloaded with a language runtime and other components that are required to run the image on Lambda. AWS provides a Dockerfile for each of the base images to help with building your container image.
-
Open-source runtime interface clients
If you use a community or private enterprise base image, add a runtime interface client to the base image to make it compatible with Lambda.
AWS provides the following base images for Python:
Tags | Runtime | Operating system | Dockerfile |
---|---|---|---|
3, 3.8 | Python 3.8 | Amazon Linux 2 | Dockerfile for Python 3.8 on GitHub |
3.7 | Python 3.7 | Amazon Linux 2 | Dockerfile for Python 3.7 on GitHub |
3.6 | Python 3.6 | Amazon Linux 2018.03 | Dockerfile for Python 3.6 on GitHub |
2, 2.7 | Python 2.7 | Amazon Linux 2018.03 | Dockerfile for Python 2.7 on GitHub |
Docker Hub repository: amazon/aws-lambda-python
Amazon ECR repository: gallery.ecr.aws/lambda/python
Install the runtime interface client for Python using the pip package manager:
pip install awslambdaric
For package details, see Lambda RIC on the Python Package Index (PyPI) website.
You can also download the Python runtime interface client from GitHub.