Giter VIP home page Giter VIP logo

lambda-atlas-microservice's Introduction

lambda-atlas-microservice

  • Each Microservice is versioned

  • Under each version, you many have one more controller ( and its corresponding models). Controller is a logical separation for microservice. Depending on how you want your service boundary, you may have either one or more controller in your microservice.

  • There will be multiple API endpoints / routes in a microservice

Let's take a example Game application which have microservices such as Game, Results.

Microservice 1 - Game

Game microservice is versioned and have many API endpoints rules, players with different versions v1, v2

v1/ /rules /players

v2/ /rules

Sample Endpoint for a game microservice which is versioned - http://example.com/game/v1/players

Microservice 2 - Results

Services like - Atlas, Lambda have free tiers. Use that when you start developing Apps in it,

Mongo - Atlas

Create an account in Mongo DB Atlas , a fully managed cloud Mongo Database.

Create your database and collection. You can do this in console directly or through any IDE's like Mongo Compass

Following database and collection is created.

Database - game Colection - players

Lambda

Here each microservice represented as a single lambda.

Deployment is straightforward for Lambda. You just have to Navigate to Lambda in AWS console and upload your application Zip.along with node_modules and code. You can also give a s3 path of the code.

When you zip your package, make sure your index.js is correctly mapped which you give in handler.

Give npm install --production before zipping the source code.

Linter dependencies (ESLint) and testing dependecies like Mocha, Istanbul should go to the dev dependecies

Routing

Routing handled by routes.JSON. Based on HTTP Endpoint and URL, cooresponding controller and method is resolved

Environment Variables

DB Connection params, credentials, environemnt specific settings should go to the environment variables in Lambda

MONGODB_URI mongodb+srv://dbUser:[email protected]/dbName?retryWrites=true

Settings

Lambda console have many settings like memory, timeout .etc. You can configure as per your application load.

VPC Settings:

Give VPC Settings if you have custom VPC for your application

API Gateway

  1. Give {proxy+} save changes - For all wildcard requests.

When a create a new resource, click - Configure as proxy resource.

{proxy+} is a greedy path wherein the entire sub-resource chain is passed to your backend as path variables. (http://example.com/{proxy+} captures all of these sub-resources as path variables)    For Example:    •http://example.com/bikes/huffy/super-fast    •http://example.com/bikes/cannondale/racing/street/cool-bike    •http://example.com/wagon/radioflyer

You can also configure API Gateway for individual path depending on your use case.

  1. Map the API Gateway to the Lambda

  2. Your changes will not be reflected till you deploy. Don't forget to do it after every changes in API Gateway.

  3. You can test your service from the generated URL

Mapping Custom Domain Names

Steps to map the custom domain names

  1. Get a ACM( AWS Certifcation Manager) Certificate is the first step

AWS needs ACM certificate to route the traffic to aws resources. Request a public certificate for your domain & Validation

If you yet to register the domain, register in Route 53, it makes the process further easy

  1. Click -> Create Custom Domain Name

Give following paths for the API Traffic to resolve domains like - api

example.com,
*.example.com,
*.api.example.com,
  1. Route 53 registed domain.

Click the button - "Create Record in Route 53". AWS automatically updated the CNAMe record in ROUTE 53 for you. Verification will take some time and automatically verified.

  1. Other Registar

    Let's take an example - GoDaddy.

     1) You have an option 
    
         a) DNS Validation
    
          You have to manually update the DNS records in Godaddy Domain Manager
    
    
         b) Email Validation.  - This is straightforward process. Email will be sent to Domain registar'c contact email. Just you ahve to approve with the link. First try with Email Validation, if you are not getting the email, you can do via DNS Validation
    

lambda-atlas-microservice's People

Contributors

coder-m9 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.