https://github.com/batjko/serverless-aws-starter
A quick example of a Lambda function setup on AWS, using the serverless framework.
https://github.com/batjko/serverless-aws-starter
aws-lambda babel chuck-norris-jokes es6 nodejs serverless webpack2
Last synced: 2 months ago
JSON representation
A quick example of a Lambda function setup on AWS, using the serverless framework.
- Host: GitHub
- URL: https://github.com/batjko/serverless-aws-starter
- Owner: batjko
- Created: 2017-06-24T17:37:21.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-26T07:10:28.000Z (almost 4 years ago)
- Last Synced: 2024-04-14T07:08:48.238Z (almost 2 years ago)
- Topics: aws-lambda, babel, chuck-norris-jokes, es6, nodejs, serverless, webpack2
- Language: JavaScript
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://aws.amazon.com/free/))
2. Set up a [new admin user](https://serverless.com/framework/docs/providers/aws/guide/credentials#creating-aws-access-keys), to get an API key and a secret.
3. Install the [serverless CLI](https://serverless.com/framework/docs/providers/aws/guide/installation/)
4. [Configure it to use the admin user](https://serverless.com/framework/docs/providers/aws/guide/credentials#setup-with-serverless-config-credentials-command).
5. Clone this repo, cd into it and `npm i` to install the dependencies
6. [Deploy](https://serverless.com/framework/docs/providers/aws/guide/deploying/) the thing as-is, typing `serverless deploy`.
## Testing the Lambda function
If the deployment was successful, you will see a URL. Something like:
```yaml
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:
```json
{
"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](https://serverless.com/framework/docs/providers/aws/guide/serverless.yml) 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.