Rockset + AWS Lambda
- This guide assumes that you are familiar with AWS Lambda.
- The instructions below require Python3.7 or higher for installation.
- Please read the blog post on rockset.com for instructions and details on using this example.
- Clone this repository.
- Enter the rockset-aws-lambda/python-lambda directory, open
credentials.pyand fill in your Rockset
- Run the
build-package.shscript from that directory. This script downloads the dependencies and packages it up into a functions.zip file. This is the zip that we will upload to AWS Lambda
- Create an AWS Lambda function. You can do this using the below command. You will need to create/use the appropriate role in the command. See lambda roles for details.
aws lambda create-function \ --function-name my-function \ --runtime=python3.7 \ --role=<specify-role-here> \ --handler=lambda_function.lambda_handler \ --zip-file fileb://function.zip
You can set up API Gateway to serve the lambda once it has been uploaded. Detailed instructions can be found in the create an API with the Lambda Custom Integration tutorial.
- Once the API Gateway and endpoint is set up and operational, you can use it within the sample web application.
- Open rockset-aws-lambda/js-app/assets/js/script.js.
- Fill in the
LAMBDA_URLfield within the JS file with the API endpoint URL.
- Run a local Python HTTP server and serve index.html to run the webpage.
Updating the lambda
If you're experimenting and iterating on the lambda function by changing the query, you can update the lambda using the below command.
aws lambda update-function-code \ --function-name my-function \ --zip-file fileb://function.zip