Coder Social home page Coder Social logo

lambda-example's Introduction

AWS Lambda Example Project

Build Status Test Coverage Dependabot Status Dependencies NPM Downloads Semantic-Release Gardener

Pure Lambda: Lambda + Tests + Serverless

This is an example for AWS Lambda Development showcasing how to use:

A list of all the example handlers with description can be found here. Each handler has tests files associated.

Note: Independent of the Lambda trigger type.

HTTPS Endpoint: Lambda + Tests + Serverless + Api Gateway

This is an example for AWS Lambda Development showcasing how to use:

A list of all the example handlers with description can be found here. Each handler has tests files associated.

Note: Lambda functions defined this way are expected to be used with API Gateway.

Getting Started

Install serverless with

$ npm install -g serverless

Then verify tests with

$ npm test

Deploy Project to AWS

To deploy run

$ sls deploy

Things to try after deploy

Simple Functions

Test a geoip function

$ sls invoke -f geoip

Test div function

$ sls invoke -f div -d '{ "a": 32, "b": 5 }'

Mode detail on the invoke option can be found here.

You can also log into AWS and trigger the function with an event that you manually create.

Https Endpoint

The deploy message will give you a public url to use of the form https://##########.execute-api.us-east-1.amazonaws.com/example/sum. Experiment with different input, e.g.

$ URL
$ URL?input=[1,4,2,45,6]
$ URL?input=[1,4,2,45,]

Swagger Documentation

Swagger documentation is automatically synchronized using the API definition, but also manually enriched. For an example on how this is accomplished see test_https.js. The generated swagger file can be found here.

The file also contains a test example that ensures that the swagger documentation is synchronized with the serverless.yml file.

Rate Limit

If you hit the endpoint many times quickly you will trigger the rate limit.

Rollbar Monitoring

Set up your rollbar account and fill the details into the example.yml. Then deploy again and check that information is logged to rollbar as you hit warning / error conditions!

Remove Project from AWS

Run

$ sls remove

Other Considerations

Monitoring

Consider using lambda-monitor for monitoring your lambda function.

lambda-example's People

Contributors

dependabot-preview[bot] avatar simlu avatar mrsflux avatar greenkeeper[bot] avatar dependabot-support avatar greenkeeperio-bot avatar kodiverse avatar dependabot[bot] avatar macmcirish 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.