This is a simple Node.js AWS Lambda seed to get you going. It uses
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.
npm i -g aws-sdk
to install AWS SDK if you haven't already.npm i
in repo directory to build node modules.npm run start
to try it out (locally)! Everything works, right? Good! Let's get it into the cloud...- Configure aws-sdk in your home directory. Ensure the Lambda-controlling
aws_access_key_id
andaws_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. - Create a Lambda function on AWS. Edit
.env
to your Lambda function; and function name inpackage.json
. npm run deploy
to push into the cloud...- 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 inevent.json
. Look atdeploy.env.example
if you want to send along secret variables (change name todeploy.env
) that don't go to git.
- Go to the AWS Lambda console and create two aliases,
PROD
andSTAG
. - Point
STAG
to$latest
version. This way, whenever you deploy,STAG
will always use the newest deployment. - Ready to update
PROD
? Usenpm run updateProd
and it will create a new version from$latest
and pointPROD
to that version. - How to use this setup? When you invoke a Lambda function from, e.g., API
Gateway, you can choose, e.g.,
MyFunctionName:PROD
, and useSTAG
for, well, staging or development.