The ZotbinsLambda project organizes the Lambda functions used for manipulating the bin metric data from the deployed smart bins.
First clone this project:
git clone https://github.com/zotbins/ZotbinsLambda.git
In order to run this project, we'll need:
- The Serverless Framework
- Serverless Offline
- Serverless Python Requirements
To install Serverless Framework, run:
npm install serverless -g
This command installs serverless globally, so you won't need a separate serverless package for other npm projects.
To install all the necessary npm packages, run:
npm i
Not necessary, but nice to know for future projects: To install Serverless Offline, run:
npm install serverless-offline --save-dev
To install Serverless Python Requirements:
sls plugin install -n serverless-python-requirements
To install the necessary python modules, run:
pip install -r requirements.txt
Before you begin, make sure to visit the following link to install docker: https://docs.docker.com/get-docker/.
Docker is used to be create a TimescaleDB database to test our data locally. To install, run:
docker run -d --name timescaledb -p 5432:5432 -e POSTGRES_PASSWORD=password timescale/timescaledb:latest-pg12
This creates a Docker named TimescaleDB that will run on port 5432. TimescaleDB utilizes PostgresSQL, so the password to access the underlying PostgresSQL database remotely is just "password" since this docker database is just for local testing.
We can also directly access the PostgresSQL database by running:
docker exec -it timescaledb psql -U postgres
But it would be more convenient to create the tables by running the create_tables.py script. Just make sure that the docker container has started by running:
docker start timescaledb
python create_tables.py
To run the project locally, use
sls offline
The project should be hot reloadable, so you should see changes after you save a file.
And we can then manipulate the data inside there.