Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions issue_29/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Containerizing Lambda Function
## This Doc provides a step by step process that can be followed to containerize the Lambda Functions

---

## 🚀 Why Containerize AWS Lambda?

### 🔧 Traditional Method (Zip-based)
- Limited to 250 MB unzipped package size (including dependencies)
- Can't install OS-level packages easily
- Not ideal for ML models with large libraries and complex dependencies such as PyTorch and TensorFlow
### 🐳 Containerized Lambda (Docker-based)
- Package size up to **10 GB**
- Full control and transparency over the **runtime and OS level libraries**
- Use/Define any dependencies not supported by AWS Lambda runtime
- Easier **local testing and reproducibility**

---

## High level Steps
- Create the logic code that contains the handler class for lambda function
- Define dependencies in the requirements.txt
- Create the Docker file, inside docker file make sure to define
- Commands to install dependencies
- Add the function code
- set the handler function
- any other required dependency jars/libraries installation
- Create an amazon ECR registry repo
- To deploy a containerized Lambda, you must upload the image to Amazon ECR (Elastic Container Registry) first. That’s the only way AWS Lambda can pull your container image.
- Authenticate Docker ot ECR, tag the Docker image to ECR and push the image to ECR

## Once the lambda is containerized and pushed to ECR, it can be deployed from the ECR image.
```bash
Sample Code

aws lambda create-function \
--function-name provide_func_name \
--package-type Image \
--code ImageUri=<ecr_image_uri> \
--role give_the_required_iam_role

```
## References
- [Deploy Lambda functions with container images](https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/deploy-lambda-functions-with-container-images.html)
- [Deploy Python Lambda functions with container images](https://docs.aws.amazon.com/lambda/latest/dg/python-image.html)