Creating RESTful services in AWS Lambda

14,700

Solution 1

Correction :

Amazon has launched - Amazon API Gateway which used Lambda

What Is Amazon API Gateway?

API Gateway helps developers deliver robust, secure, and scalable mobile and web application back ends. API Gateway allows developers to securely connect mobile and web applications to business logic hosted on AWS Lambda, APIs hosted on Amazon EC2, or other publicly addressable web services hosted inside or outside of AWS. With API Gateway, developers can create and operate APIs for their back-end services without developing and maintaining infrastructure to handle authorization and access control, traffic management, monitoring and analytics, version management, and software development kit (SDK) generation.

API Gateway is designed for web and mobile developers who are looking to provide secure, reliable access to back-end APIs for access from mobile apps, web apps, and server apps that are built internally or by third-party ecosystem partners. The business logic behind the APIs can either be provided by a publicly accessible endpoint API Gateway proxies call to, or it can be entirely run as a Lambda function.

https://aws.amazon.com/api-gateway

As of today; AWS Lambda is focused on working out / responding to events like S3 put, DynamoDB Streams and also custom events [ there could be more event sources expected from Amazon ] - with heavily leveraging the STATELESSNESS style of programming.

To build out a complete RESTful Service backend using AWS Lambda wouldn't be possible or in other words AWS Lambda would be a bad choice to build the RESTful Service. You can continue to use the NodeJS and make it run on top of EC2 or ElasticBeanstalk.

Solution 2

As of the last month, the answer has changed. AWS Lambda functions can now return a synchronous response and AWS is now encouraging the use of Lambda as a mobile backend or potentially a full REST API.

Documentation is a bit sparse at the moment, but you can start reading about it here for now: http://aws.amazon.com/lambda/whatsnew/

Solution 3

Amazon now supports this directly with the API Gateway service. This post is a great rundown of how to get started.

Solution 4

The answer is Yes it is possible to build RESTful services using AWS lambda for websites to consume.

Your question has been answered by Tim Wagner of Amazon at a conference presentation where an audience member asks a very similar question to yours.

Question

"If you want to trigger a lambda function based on a regular old web request coming in from a user on the internet ... they hit an address and they sent in a bunch of query parameters ... So theres just this one stateless kind of thing that comes in with a bunch of data and then you want to trigger a lambda function off of that? ... what are the options there? ... to fire off that node.js workload?"

Answer 1

"... use something like beanstalk to create a web app. And then inside that webapp invoke the lambda functions for the portions of your workload or scenario that make sense to do"

Answer 2

"... If you're able to ... constrain your calls to match lambda's request model then you can skip that (beanstak webapp) and simply call us as if we were a web service proxy for you"

https://youtu.be/copO_JQQsBs?t=50m53s


As for the node part of your question.

The answer is yes you can develop your Lambda function using node.js

Please refer to the Webinar from Amazon below.

"The language that we have support for today is node.js"

https://youtu.be/YEWtQsqIYsk?t=25m22s

Share:
14,700
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    As I gone over the AWS Lambda documentation, there are references on triggering services based on AWS events. I do not see references on hosting services in Lambda.

    Would like to understand whether is it possible to create RESTful services using AWS Lambda for web sites to consume or not?

    I can use NodeJs to develop the service.