Skip to content

A quick example of a Lambda function setup on AWS, using the serverless framework.

Notifications You must be signed in to change notification settings

batjko/serverless-aws-starter

Repository files navigation

Serverless Example w/ Webpack

Simple starter project setting up a single /healthCheck API endpoint that is resolved by a small but incredibly important Lambda function, which returns a status 200 and an object with a random Chuck Norris fact.

Installation / Setup

  1. Get an AWS account (I recommend the Free Tier)
  2. Set up a new admin user, to get an API key and a secret.
  3. Install the serverless CLI
  4. Configure it to use the admin user.
  5. Clone this repo, cd into it and npm i to install the dependencies
  6. Deploy the thing as-is, typing serverless deploy.

Testing the Lambda function

If the deployment was successful, you will see a URL. Something like:

endpoints:
  GET - https://[blabla].execute-api.[aws-region].amazonaws.com/dev/healthCheck

You can test that url in your browser or Postman, with curl or what have you. The response, if all went well, should look like this:

{
  "wisdom": "Chuck Norris once ate a whole cake before his friends could tell him there was a stripper in it."
}

If you see any errors, you most likely haven't set up your admin user correctly. Read the links back at steps 2 and 4.

Developing

Thanks to the webpack and babel config included, you can write proper ES.next code, including es6 modules, as you can see in handler.js.

Read the official serverless framework docs about how to use the serverless.yml file to set up your configuration and additional functions, including more REST endpoints (API Gateway) and resources like DynamoDB tables or S3 buckets etc.

Enjoy.

About

A quick example of a Lambda function setup on AWS, using the serverless framework.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published