Friday, November 11, 2016

Deploying Node JS Apps to Amazon Lambda In 5 Minutes:

AWS Lambda is a bit of a game-changer for developers who don't have the means, or the desire to mess with devops, even in the simplified world of containers.  We just write some code, put it somewhere. When a request comes in, resources are automatically allocated to running that code, the code is executed, and then the resources are deallocated.  In Lambda, we are only billed when our software is actually run.  The costs can be almost free to host websites with very little traffic.  Unfortunately, these things are not easy to start up and configure using the tools Amazon provides.  But, and open source utility called serverless has makes it really easy!

Here's how:
  • Signup / Log into Amazon AWS
  • Create an IAM AWS Access Key ID and AWS Secret Access Key here. You'll need these in a second.
  • npm install -g serverless
Run the following on the command line:
$ export AWS_ACCESS_KEY_ID=YOUR_KEY_ID_HERE       $ export AWS_SECRET_ACCESS_KEY=YOUR_ACCESS_KEY_HERE $ mkdir teset&& cd test $ serverless create --template aws-nodejs

Edit the serverless.yaml file and uncomment the following lines 
    events:       - http:           path: users/create           method: get

And, run:
serverless deploy
After a few seconds, your server's URL should be printed.  Just edit handler.js to add functionality to your application.


No comments:

Post a Comment

AddThis

Bookmark and Share