GithubHelp home page GithubHelp logo

nengkhoiba / express-aws-lambda Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashiqsultan/express-aws-lambda

0.0 1.0 0.0 370 KB

This is boiler plate code to develop and deploy express app to AWS lambda.

JavaScript 100.00%

express-aws-lambda's Introduction

Express JS in AWS Lambda

This is a boiler plate code to deploy Express in AWS Lambda using Serverless JS. Using this you can built Express APIs in your local machine and deploy them in AWS lambda with just few commands.

Run the local.js file to test the application locally

npm install
npm start

About the files and folders

  • lambda.js - File which is called by AWS lambda
  • local.js - Run the app on localhost.
  • src/app.js - Your App logic
  • serverless.yml - Lambda function configration.

How to use

  • Both the lambda.js and local.js calls the express app in the src/app.js
  • Write your business logic (Express API) inside the src folder
  • npm start runs the local.js file to test the app in your local machine
  • serverless.yml file contains your details about your AWS region and name of your Lambda function, they are self-explanatory edit them to your needs
  • Leave the lambda.js an local.js file alone unless you know what you are doing

Prerequisites for Deploying in AWS

  • An AWS account
  • AWS CLI installed in your machine

AWS Configrations

Download and install AWS CLI. After installing run the following command in the terminal to configure your AWS account.

aws configure

it will ask for Access Key and Secret key, you can find them in your AWS online console.

Deployment

Run the following command to deploy the app as AWS Lambda function

npm run deploy

##After deployment

  • Go to your AWS console and choose Lambda from Services.
  • You can find your deployed function in list.
  • Find the URL to invoke your function in the API endpoint.
  • Your endpoint URL should look something like this
https://abcd123.execute-api.us-east-1.amazonaws.com/production/{proxy+}

##Invoke your function omit the ' {proxy+} ' and use the rest of the URL to call the function

https://abcd123.execute-api.us-east-1.amazonaws.com/production/

The above URL outputs the responce in app.get('/', (req, res) => {}) in the app.js file

express-aws-lambda's People

Contributors

ashiqsultan avatar

Watchers

James Cloos 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.