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-sdkto install AWS SDK if you haven't already.npm iin repo directory to build node modules.npm run startto 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_idandaws_secret_access_keyare in, e.g.,~/.aws. This way you don't have to keep this in.envwhich I prefer to keep in version control. - Create a Lambda function on AWS. Edit
.envto your Lambda function; and function name inpackage.json. npm run deployto push into the cloud...- Go to AWS Lambda console and test if it works. It does, right? Great! Start
editing
index.jsto whatever you want. You can mock data inevent.json. Look atdeploy.env.exampleif 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,
PRODandSTAG. - Point
STAGto$latestversion. This way, whenever you deploy,STAGwill always use the newest deployment. - Ready to update
PROD? Usenpm run updateProdand it will create a new version from$latestand pointPRODto 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 useSTAGfor, well, staging or development.