https://github.com/bluepeter/aws-lambda-nodejs-boilerplate
Simple seed to get your AWS Lambda function into the cloud.
https://github.com/bluepeter/aws-lambda-nodejs-boilerplate
aws-lambda aws-sdk cloud node-lambda nodejs serverless
Last synced: 6 days ago
JSON representation
Simple seed to get your AWS Lambda function into the cloud.
- Host: GitHub
- URL: https://github.com/bluepeter/aws-lambda-nodejs-boilerplate
- Owner: bluepeter
- License: mit
- Created: 2017-03-13T12:09:45.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-22T07:07:54.000Z (almost 8 years ago)
- Last Synced: 2025-05-13T04:38:41.086Z (8 days ago)
- Topics: aws-lambda, aws-sdk, cloud, node-lambda, nodejs, serverless
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Simple AWS Lambda Node.js Boilerplate
This is a simple Node.js AWS Lambda seed to get you going. It uses
[node-lambda](https://github.com/motdotla/node-lambda) for locally running and
deploying. It logs with Bunyan, and has a simple async waterfall in it's
`index.js` to give you one approachin handling flow control in a Lambda
function.### Basic
1. `npm i -g aws-sdk` to install AWS SDK if you haven't already.
2. `npm i` in repo directory to build node modules.
3. `npm run start` to try it out (locally)! Everything works, right? Good!
Let's get it into the cloud...
4. Configure aws-sdk in your home directory. Ensure the Lambda-controlling
`aws_access_key_id` and `aws_secret_access_key` are in, e.g., `~/.aws`. This
way you don't have to keep this in `.env` which I prefer to keep in version
control.
5. Create a Lambda function on AWS. Edit `.env` to your Lambda function; and
function name in `package.json`.
6. `npm run deploy` to push into the cloud...
7. Go to AWS Lambda console and test if it works. It does, right? Great! Start
editing `index.js` to whatever you want. You can mock data in `event.json`.
Look at `deploy.env.example` if you want to send along secret variables
(change name to `deploy.env`) that don't go to git.### Advanced
8. Go to the AWS Lambda console and create two aliases, `PROD` and `STAG`.
9. Point `STAG` to `$latest` version. This way, whenever you deploy, `STAG`
will always use the newest deployment.
10. Ready to update `PROD`? Use `npm run updateProd` and it will create a new
version from `$latest` and point `PROD` to that version.
11. How to use this setup? When you invoke a Lambda function from, e.g., API
Gateway, you can choose, e.g., `MyFunctionName:PROD`, and use `STAG` for,
well, staging or development.