Thanks to visit codestin.com
Credit goes to github.com

Skip to content

eduardfores/CQS_Weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License LinkedIn


Logo

Serverless Weather in AWS with Edge-Computing

This project is one serveless application with edge-computing concept executing one little database in SQLite in the client browser.

Demo

Table of Contents
  1. About The Project
  2. Getting Started
  3. AWS Architecture
  4. License

About The Project

The project contain one website connected to s3 to download the necessary database to show the weather in different places of the world (Madrid, London, Paris). The files download from the S3 are .db files (little files with databases in SQLite). These files are load in the SQLite wasm in the client side and this client process the database in the browser to show the data.

To simulate the IoT writers I create different lambda functions to send messages with the weather data to SQS and other lambda to receive all messages and create the .db file of the day execution.

So in this project there are:

  • Hosting Static web in S3
  • The web reads from S3 bucket the database.db files
  • SQLite executions in the client side
  • SQLite creation files using python and save it in S3
- The demo may be doesn't charge good the website because the first .db file searched is the current date. e.g. database08-04-2022.db
- To execute this project change the name of the databasedd-mm-yyyy.db with the current date and add it in your S3 Bucket inside the /database directory

(back to top)

Built With

This section list the frameworks/libraries used to create this blog.

(back to top)

Getting Started

In this section I explain you about how you can import this project to your AWS account to test it.

Prerequisites

This is an example of how to install the functions you need to use the software and how to install them.

  • S3 configuration

You have to configure S3 with static host endpoint Hosting Static in AWS

All files in this bucket must be PUBLIC

  • SQS configuration

You must create a standard queue in SQS service Create queue in AWS

You can create a FIFO queue but for this project is not necessary

  • IAM premissions

You must create one user to give permissions to put files in S3 you can use the file PutObject.json to create these permissions. This user will used fom the Lambda function to save the .db files in /databases directory of your S3 Bucket. The ACCESS_KEY and SECRET_KEY have to be add in the python file S3 Client.

Other user necessary for this project is one user with the permissions in SQS to administrate the queue you can use the default policy created by AWS with full access in SQS the name of this policy is AmazonSQSFullAccess. The ACCESS_KEY and SECRET_KEY have to be add in the python files SQS Client and CQS_Weather_Madrid.

The credentials to read S3 from the HTML you have to fill the information of credentials.js. In this case we don't need a user because we use the cognito-identity directly. The permisions for this new rol can be ListObject.json

Installation

Below is the instructions to install the the application in AWS Step by step.

  1. Upload all files related with the Web page in S3 bucket configured previouslly. You must upload all content of [cqs-weather]https://github.com/eduardfores/CQS_Weather/tree/main/cqs-weather) directory in the root of the Bucket.

  2. Create 1 lambda function to generate the weather data and send the messages to SQS CQS_Weather_Madrid.py. Remember to add ACCESS_KEY and SECRET_KEY.

  3. Create other lambda function to receive the messages from SQS and generate the .db files and save it in your S3 Bucket CQS_Weather_SQLite3.py, copy/paste all files inside the repository. Remember to add ACCESS_KEY and SECRET_KEY.

  4. To automate the functions create different events one for the writers of SQS and other for the reciver of SQS. You have to link them in the trigger of every lambda.

With the step one you will have a serverless static website executing SQLite in the browser.

(back to top)

AWS Architecture

The Architecture can be expressed with the next diagram

Diagram

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

About

This project offer a option to execute sqlite in client browser with AWS S3 storage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published