Technologies used: Snowflake, Python, Flask, AWS API Gateway, AWS Lambda, Serverless Framework
Requirements:
- Snowflake.com and Serverless.com account
- node.js, python 3, virtualenv installed
This project demonstrates how to build and deploy a simple Ad Tag powered by Snowflake. It uses a simple Python Flask API service running on AWS Lambda using Serverless Framework.
Copy the serverless-template.yml to serverless.yml and modify the parameters according to your Snowflake configuration. Put your private key to your Snowflake user in AWS SSM is us-west-2 region under the parameter .DATA_APPS_DEMO.
Install serverless and other required node packages and configure serverless (sls) for the project.
npm install
sls loginCreate a virtualenv locally and install python packages.
virtualenv venv --python=python3
source ./venv/bin/activate
pip install -r requirements.txtFor local development you will want to use the venv previously created. This will run a local application server and connect to your Snowflake account for data access.
Start the local serverless server.
sls wsgi serveAfter successful startup, you can call the created tag via HTTP:
curl http://localhost:5000/?adid=1234&placementid=abcd&creativeid=6789Which should result in an empty result and a 204 no content status.
Build and deploy the application to AWS. For your first time, you will have to run sls without deploy to configure the project.
sls deployAfter successful deployment, you can call the created application via HTTP:
curl https://xxxxxxx.execute-api.us-west-2.amazonaws.com/dev/Which should result in an empty result and a 204 no content status.
By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in To request a limit increase for concurrent executions.