This project is a Proof of Concept about using the Amazon Web Services, mainly focusued on serverless, hence AWS Lambda Functions.
The idea of the project was to find a dataset served with open data and try to build a simple project where:
- The dataset is uploaded into a AWS Database, in this case DynamoDB;
- Various AWS Lambda offers the opportunity to perfrom CRUD actions (this project)
- A frontend performs the actions offered by the Lambda ecosystem and that makes available these actions to the final users.
The dataset used has been downloaded from Regione Sardegna Open Data in October, 2021.
In the image below it can be seen the architecture of this simple PoC. In details:
- The dataset is loaded into DynamoDB
- Various AWS Lambdas implements the CRUD operations using the data in the DB
- The AWS Lambdas are exposed using an API Gateway
- Finally, a Frontend Webapp uses the data across REST requests performed throught the API Gateway.
This project implements 6 different Lambda functions:
- GetAll -
GET /points
: it performs a scan in DynamoDB and returns every record from the DB; - GetOne -
GET /points/:id
: given in input an ID, it returns a single record - Create -
POST /points
: it creates a new record in the DB; - Update -
PUT /points/:id
: given an ID and a body, it updates a record in the DB; - Delete -
DELETE /points/:id
: given an ID, it removes a record from the DB - Init -
POST /points/init
: this function is commented in theserverless.yml
file and it is used for populate the DB. It is recommended to limit the init records in the functions (with adataset.slice(0, 100)
for example) in order to avoid requests in timeout.
Before everything, serverless framework is required:
npm install -g serverless
After the installation, it is required to login with a AWS Account in the shell. Follow the serverless guide for more informations. After having performed the login, you just have to execute these commands:
# Install project dependencies
npm i
# Run the lambdas in local
serverless offline start -s dev