Deploying Loopback application on AWS Lambda

1,657 views
Skip to first unread message

AKB

unread,
Apr 23, 2018, 1:44:02 AM4/23/18
to LoopbackJS
Hi,

I need to deploy my loopback application on AWS Lamdba. Any idea how to achieve this?

Thanks,
AKB

Mark Johnson

unread,
Apr 23, 2018, 1:54:53 AM4/23/18
to LoopbackJS
I'm not sure why you would NEED to deploy loopback on Lambda.  Lambda is designed for very lightweight function sets, not full frameworks.  A lot of traffic could also prove rather costly compared to say Fargate.  I would think Fargate or ECS would be more suitable options.

AKB

unread,
Apr 23, 2018, 2:02:31 AM4/23/18
to LoopbackJS
Thanks for the quick reply.

I have a very small application that is already build in lookback but needs to be deployed on lamba. Is there some utility available to convert the loopback back to something that i can deploy on lambda? Or if you can guide me what changes I need to make in "index.handler" of lambda function to call different loopback end points?

Mark Johnson

unread,
Apr 23, 2018, 4:57:20 AM4/23/18
to LoopbackJS
And here's the problem, Lambda needs to return a callback to indicate success state. Loopback isn't designed to do this; it is designed to return data to a request object, not work with the Lambda callback chain.  I don't see an easy fix for this - it's just the wrong tool for the wrong model.  Again, I'd ask why there is a requirement to use Lambda?  

The only thing I can think of is to have a Lambda function calling another service (docker, or EC2), but then you'd just be replicating the API anyway.

Rishi Patel

unread,
Oct 24, 2018, 4:13:25 AM10/24/18
to LoopbackJS
Hi AKB,
I'm no AWS expert of anything like that, but as long as I know what you want, can be achieved with AWS API gateway and lambda.
  • API Gateway will act as a controller similar to any express (loopback) app
  • AWS Lambda will run the code logic and return the output
As I already said I'm also new to these things and also exploring these areas same you, but I do know that API Gateway and AWS Lambda are what you need here. 
So look for ways to working with API Gateway and Lambda and you might get the answer to your question until someone else with better AWS services understanding replies to this thread.
Rishi

marcelobern

unread,
Dec 2, 2018, 5:50:25 PM12/2/18
to LoopbackJS
Hi AKB,

I came across this thread and figured I could lend a hand, so I put together a very basic sample on how to use loopback on AWS lambda.

I used the serverless framework to get all the AWS infrastructure ready and because it has a simple way to wrap express applications ;-)

You can find the sample code here: https://github.com/botbits/serverless-loopback

Please note that running loopback in lambda is a bit different than on a regular web server. For example, loopback boot scripts get executed multiple times (each time a lambda instance starts) so you may need to adjust your code when moving to lambda.

Please feel free to reach out in case you have any questions and I will do my best to answer them.

Have a great week!

Marcelo

marcelobern

unread,
Dec 19, 2018, 7:10:31 PM12/19/18
to LoopbackJS
And here is a companion article on explaining the approach: https://medium.com/smac-4u/serverless-loopback-9ff0d6fa539d

Have fun!
Reply all
Reply to author
Forward
0 new messages