Skip to content
This repository was archived by the owner on Dec 29, 2023. It is now read-only.

Commit 0721e51

Browse files
committed
lambda alpha
1 parent f3babd2 commit 0721e51

File tree

5 files changed

+49
-0
lines changed

5 files changed

+49
-0
lines changed

lambda/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM public.ecr.aws/lambda/python:latest
2+
COPY lambda.py ./
3+
COPY requirements.txt ./
4+
RUN python3 -m pip install -r requirements.txt
5+
6+
CMD ["lambda.lambda_handler"]

lambda/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# chDB on AWS Lambda
2+
3+
> Running chdb in a lambda function for fun a profit!
4+
5+
This guide is based on [this article](https://medium.com/@skalyani103/python-on-aws-lambda-using-docker-images-5740664c54ca)
6+
7+
## Upload Docker image on ECR and Lambda
8+
Lambda function continers must be hosted on the AWS Elastic Container Registry.
9+
10+
1. Export your AWS account id in the shell or better yet, add it your ~/.bashrc or ~/.bash_profile
11+
```
12+
$ export AWS_ACCOUNT_ID = <account_id>
13+
```
14+
15+
2. Install the AWS CLI and configure with your AWS credentials
16+
```
17+
$ aws configure
18+
```
19+
20+
3. Review and execute the ‘deploy.sh’ script:
21+
```
22+
$ ./deploy.sh
23+
```
24+
25+
4. Create Lambda function and attach your ECR Image
26+
27+
5. Test your Lambda function:
28+

lambda/deploy.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
URL_STRING=".dkr.ecr.us-east-1.amazonaws.com"
2+
CONTAINER_STRING="chdb"
3+
IMAGE_STRING="latest"
4+
ECR_IMAGE_URI="$AWS_ACCOUNT_ID$URL_STRING/$CONTAINER_STRING:$IMAGE_STRING"
5+
# log in to ECR
6+
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin "$AWS_ACCOUNT_ID$URL_STRING"
7+
# remove previous images to save space
8+
docker rmi "$AWS_ACCOUNT_ID$URL_STRING/$CONTAINER_STRING"
9+
docker rmi "$CONTAINER_STRING"
10+
# build image
11+
docker build --tag "$CONTAINER_STRING" .
12+
# tag and push to AWS ECR
13+
docker tag $CONTAINER_STRING:latest "$ECR_IMAGE_URI"
14+
docker push "$ECR_IMAGE_URI"
File renamed without changes.

lambda/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chdb

0 commit comments

Comments
 (0)