Skip to content

stefanoabalsamo79/test-data-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Architecture for test-data-api

Simple architecture for apis use case. Below the components involved.

Api Gateway

Component working as interface towards the outer world and functioning as proxy to dispatch request against the lambdas correctly configured behind and attached to it via resources, method and integration

Lambdas

  • apiProjects lambda (Readme can be found here)
  • apiComments lambda (Readme can be found here)
  • apiIssues lambda (Readme can be found here)

This lambdas are meant to work as REST endpoints serving 3 different entities, respectively projects, comments and issues

Database

Fake database emulated retrieving data from a json file (path: data/db.json) having in it the entities mentioned above presented as array of objects

Architecture diagram

Here a simple diagram to give the idea of the infrastructure:

Architecture Diagram

Getting started

Requirements

In order to run this example you need:

  • An AWS account (with AWS cli installed and configured)
  • Terraform (0.11+)

Configuration

Creating IAM users (console)

Terraform configuration

One approach can be for instance once your aws credentials are created, export this var in your .bash_profile file:

export AWS_ACCESS_KEY_ID=XXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXX
export AWS_DEFAULT_REGION=eu-west-1

Deployment

In order to deploy this solution below all the task we can perform via make file:

make package # create the lambda packages under the folder ./build and respectively `api-projects.zip`, `api-comments.zip`, `api-issues.zip`
make create_bucket # create your create_bucket on aws s3 where to deploy your lambda's artifact code
make deploy_artifacts # deploy the lambda packages against bucket s3://artifact-lamdas
make clean # clean up your build folder
make apply # perform terraform apply so deploying all the infrastructure
make destroy # perform terraform destroy and then remove all the infrastructure

Testing the existing endpoint from cli or browser

After the deployment you will see as output AWS Api Gateway the base invoke url:

Architecture Diagram

curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/stage1/projects
curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/stage1/projects/1/comments
curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/stage1/comments
curl https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/stage1/issues

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published