Headstart Microservices Architecture using AWS Lambda in your favorite programming language (Node.js or Python or JAVA)

The way we build software has changed stupendously from Monolithic Architecture (MLA) using single programming language to a Microservices Architecture (MSA) where pieces of code developed in multiple different programming language that fits the problem in hand. Microservice has numerous benefits and encourages Single Responsibility Principle (SLP) with quick deployment and easy to change lifecycle without impacting the fatty software.

AWS offers easy way to implement microservices through RESTful APIs wrapped against AWS Lambda functions in a server less backend that can auto scale with built in security via its IAM. AWS offers 12 months free tier which enable you to get hands-on experience with AWS Cloud Services.

To demonstrate the power of AWS API Gateway & Lambda, I quickly dropped my flicker photo search node.js code as lambda function wrapped in AWS API Gateway and exposed it as REST API Endpoint.


var Client = require('node-rest-client').Client;
var _ = require("underscore");
var json2xls = require('json2xls');
var fs = require('fs');
//API Explorer : https://www.flickr.com/services/api/explore/flickr.photos.search
var flickr_api_endpoint = "https://api.flickr.com/services/rest/?method=flickr.photos.search&format=json&nojsoncallback=1";
var flickerPhotos = [];
exports.handler = function (request, context) {
//1) Resolve input and execute REST calls
try {
var flickr_api_key = request.api_key;
var flickr_search_tags = request.search_tags;
var flickr_search_text = request.search_text;
var flickr_search_limit = request.search_limit;
var flickr_search_currentpage = request.search_currentpage;
flickr_api_endpoint = flickr_api_endpoint + "&api_key=" + flickr_api_key + "&tags=" + flickr_search_tags + "&text=" + flickr_search_text + "&per_page=" + flickr_search_limit + "&page=" + flickr_search_currentpage
var client = new Client();
client.registerMethod("flickrSearch", flickr_api_endpoint, "GET");
catch (e) {
context.fail("Something wrong in the input! please check. [" + e.message + "]");
//2) Process REST call response and send it back to the client.
var args = { headers: { "Content-Type": "application/json", "Cache-Control": "no-cache" } };
client.methods.flickrSearch(args,function (res, rawdata) {
try {
console.log("Length = [" + res.photos.photo.length + "]");
_.each(res.photos.photo, function (item, index, list) {
//console.log("http://farm" + item.farm + ".staticflickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_b.jpg");
flickerPhotos[index] = "http://farm" + item.farm + ".staticflickr.com/" + item.server + "/" + item.id + "_" + item.secret + "_b.jpg";
catch (e) {
view raw flickerphotos.js hosted with ❤ by GitHub

AWS lambda does not support 3rd party npm so make sure to upload all of your 3rd party node_modules. AWS Lambda & API Gateway Getting Started guide will be your good head start.


POST https://www.getpostman.com/collections/9f4773dd73a512b92e7a






RESTful API 10 Best Practices I follow

Following are the SILVER BULLETS when I create REST APIs. These were originally published here in the year 2014 and the credits goes to them but my true salute goes to OMAR AL ZABIR who published with sample source in C# in his blog post Build Truly RESTful API and Website using Same ASP.NET MVC Code way back in 2012 where he talked about RESTful services naming conventions and leveraged the Controllers  from ASP.NET MVC exported as REST API without using API.NET WEB API using content negotiation and http header (point # 5 below)



  1. Use nouns but no verbs
  2. GET method and query parameters should not alter the state
  3. Use plural nouns
  4. Use sub-resources for relations
  5. Use HTTP headers for serialization formats
  6. Use Hypermedia as the Engine of Application State (HATEOAS)
  7. Provide filtering, sorting, field selection and paging for collections
  8. Version your API
  9. Handle Errors with HTTP status codes
  10. Allow overriding HTTP method

Do not end here but head over to the above mentioned two blog posts to gain the internals.