Why did we choose lambda ric ?
- Docker images can handle larger deployments (up to 10GB)
- Perfect for bundling extensive resources like opa policies
- More efficient than ZIP files for large codebases
- Better layer management and caching
Standardization Benefits
- Consistent environments across development and production
- Same container runs locally and in Lambda
- Simplified CI/CD pipelines
- Uniform testing environment
More..
- Custom runtime configurations
- Specific system libraries
- Large framework requirements
Local testing details are in https://github.com/aws/aws-lambda-python-runtime-interface-client?tab=readme-ov-file#local-testing
We heavily use chainguard images,so build Docker image
FROM cgr.dev/chainguard/python
ARG LAMBDARIC_VERSION=3.0.0
RUN python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org --no-cache-dir awslambdaric=="${LAMBDARIC_VERSION}"
COPY --chown=root:root --chmod=755 src/ ./src # your function handlers
ENTRYPOINT [ "python", "-m", "awslambdaric" ]
CMD [ "src/handler.receiver" ]
docker build -t $docker_build_name -f your.Dockerfile .
Remember to push the image to ECR :) Or just test via
Run your Lambda image function using the docker run command.
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
--entrypoint /aws-lambda/aws-lambda-rie \
myfunction:latest \
/usr/local/bin/python -m awslambdaric app.handler
This runs the image as a container and starts up an endpoint locally at http://localhost:9000/2015-03-31/functions/function/invocations.
Post an event to the following endpoint using a curl command:
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
Remember to check the logs and clean later
docker logs "$(docker ps -q)"
echo" Stop and prune Docker containers"
docker stop "$(docker ps -a -q)"
docker system prune
Top comments (0)