Skip to content

chdb-io/chdb-lambda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chDB in AWS Lambda

Running chdb in a lambda container function

This sample shows how to run the chdb OLAP engine in an AWS Lambda function to enable ad-hoc querying of any cloud dataset with ClickHouse SQL using a simple HTTP client, without the need to run or deploy a ClickHouse cluster or dedicated cloud service.

chdb-lambda)

Create an AWS Lambda Function for chDB

Build & Push the latest chDB-lambda container image to your ECR storage.

Upload Docker image on ECR and Lambda

Lambda function continers must be hosted on the AWS Elastic Container Registry.
Before proceeding authenticate into your AWS console.

  1. Export your AWS account id in the shell or better yet, add it your ~/.bashrc or ~/.bash_profile
$ export AWS_ACCOUNT_ID = <account_id>
  1. Install the AWS CLI and configure with your AWS credentials
$ aws configure
  1. Review and execute the ‘deploy.sh’ script:
$ ./deploy.sh

➡ Search for AWS Lambda and select the service. Then, click Create Function.



➡ Choose Container Image and use the chDB ECR instance URI you created



➡ Click Create Function at the bottom right when you’re done.


Validation

Let's test our new chDB Lambda using a simple query.

The Lamba expects JSON POST requests with a query key:

curl -XPOST "http://{lambda_url}/query" \
  --header 'Content-Type: application/json'
  --data '{"query": "SELECT version()", "default_format": "CSV"}'

And the response would look like this (or any other format)

23.6.1.1

You can also use the Browser and the AWS Console to generate test events: