Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Lambda/Gateway Auto Deploy Repository

The repository serves to manage the files that are deployed on AWS lambda using github actions.

‼️ This is under construction! See the todo list at the end for more details.

Table of contents

How it works.

How the AWS server works.

Within AWS we have the following components:

  • AWS DynamoDB which serves as a key pair table.
  • AWS Lambda connecting our API Gateway with DynamoDB.
  • AWS Gateway that manages access to our routes.

How does Github actions work.

The github action uploads the index.js file into AWS Lambda using the following steps:

  • Inside the .github\workflows we have the main.yml file that builds a VM inside Github, starting a ubuntu server that make the deploy.
  • The file index.js passes through NCC for unification.
  • The output dist is ziped.
  • Finnaly the ziped file is passed to AWS lambda server.

AWS access management is done using an automated IAM user to access server acess keys.

Acess to the server

Inside our API Gateway, we have the link https://g0deojz10k.execute-api.us-east-2.amazonaws.com, were we make the request to our routes.

On the DynamoDB we are going to use the following columns structure:

  • email: This is our primary key, when the put method is called it passes trought a basic validation.
  • name: The name of the user.
  • fone: It have to be numeric.
  • createdAt: When the rows was created, is automatically generated, in Epoch with ms.
  • status: Have to be "prospect" or "client". It is set do default "prospoct".
  • lastUpdatedAt: When the rows was last updated, is automatically generated, in Epoch with ms.
  • customerAt: When the status "propspect" was changed to "customer", in Epoch with ms.

‼️ Everytime the status is changed from "prospect" to "customer" the customerAt is updated.

Our api have the following routes:

GET /leads - All items

  GET /leads

Returns the items list with the following structure:

{
  "Items": [
    {
      "status": ...,
      "createdAt": ...,
      "lastUpdatedAt": ...,
      "customerAt": ...,
      "email": ...,
      "name": ...,
      "fone": ...
    }
  ],
  "Count": 1,
  "ScannedCount": 1
}

Status codes

200

PUT /leads - New item

  PUT /leads

The item must be send with the following structure:

{
  "email": ...,
  "name": ...,
  "fone": ...,
  "status": ... (optional)
}

Remembering that as dynamo uses key pair. Returns:

{
  "email": ...,
  "name": ...,
  "fone": ...,
  "createdAt": ...,
  "status": ...,
  "lastUpdatedAt": ...,
  "customerAt": ...
}

Status codes

  • 201.
  • 409, when the email is alread on DynamoDB.

GET /lead/{email} - Specific item

  GET /lead/{email}

Where email is the email of the item without the brackets. Returns the item in Dynamo with the following structure:

{
  "Item": {
    "status": ...,
    "createdAt": ...,
    "lastUpdatedAt": ...,
    "customerAt": ...,
    "email": ...,
    "name": ...,
    "fone": ...
  }
}

Status codes

DELETE /lead/{email} - Delete item

  DELETE /lead/{email}

Where email is the email of the item without the brackets.

Status codes

PATCH /lead/{email} - Update on specific columns

  PATCH /lead/{email}

On the Json body, columns can be send to update the item. It keeps all the other columns as it is on DynamoDB.

Example:

{
	"name": "much name! such easy! wow!"
}

It returns the full item:

{
  "status": ...,
  "createdAt": ...,
  "lastUpdatedAt": ...,
  "customerAt": ...,
  "email": ...,
  "name": ...,
  "fone": ...
}

Status codes

Todo

  • Put the email as id.
  • Validate email.
  • Create the created at column.
  • Create the last update at column.
  • Create status column.
  • Create an http patch method.
  • Add correct http status to each method.
  • Create Search Methods Using Parameters.

Changelog

1.2.1 28/08/2021

  • Updated readme

1.2.0 27/08/2021

  • Changed routes from item/items to lead/leads
  • Added functions to handle Dynamo
  • Added the customerAt column
  • Removed the Post method
  • Changed project structure

1.1.0 26/08/2021

  • Email now is the primary key
  • The methods now have their http status
  • Added new columns

1.0.1 25/08/2021

  • Changed the language of the project.

1.0.0 24/08/2021

  • First version of the project with basic functionality.

About

The repository serves to manage the files that are deployed on AWS lambda using github actions.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages