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.
- Get an AWS account (I recommend the Free Tier)
- Set up a new admin user, to get an API key and a secret.
- Install the serverless CLI
- Configure it to use the admin user.
- Clone this repo, cd into it and
npm i
to install the dependencies - Deploy the thing as-is, typing
serverless deploy
.
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.
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.