https://github.com/chdb-io/chdb-lambda
chDB AWS Lambda container
https://github.com/chdb-io/chdb-lambda
Last synced: 3 months ago
JSON representation
chDB AWS Lambda container
- Host: GitHub
- URL: https://github.com/chdb-io/chdb-lambda
- Owner: chdb-io
- License: apache-2.0
- Created: 2023-07-03T13:53:32.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-31T22:52:53.000Z (almost 2 years ago)
- Last Synced: 2025-03-21T13:12:49.956Z (3 months ago)
- Language: Shell
- Size: 36.1 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.

## Create an AWS Lambda Function for chDB
➡ **Build & Push** the latest [chDB-lambda container](https://github.com/chdb-io/chdb-lambda/pkgs/container/chdb-lambda) 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 =
```2. Install the AWS CLI and configure with your AWS credentials
```
$ aws configure
```3. 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:
```bash
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)
```plaintext
23.6.1.1
```You can also use the Browser and the AWS Console to generate **test events**:
-----