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.gitIn order to run this project, we'll need:
- The Serverless Framework
- Serverless Offline
- Serverless Python Requirements
To install Serverless Framework, run:
npm install serverless -gThis 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 iNot necessary, but nice to know for future projects: To install Serverless Offline, run:
npm install serverless-offline --save-devTo install Serverless Python Requirements:
sls plugin install -n serverless-python-requirementsTo install the necessary python modules, run:
pip install -r requirements.txtBefore 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-pg12This 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 postgresBut 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.pyTo run the project locally, use
sls offlineThe project should be hot reloadable, so you should see changes after you save a file.
And we can then manipulate the data inside there.