Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a ktor application inside AWS lambda?

I don't find a way to use a ktor application inside an AWS lambda...

That is, instead of starting an embedded server or using an external server as described in http://ktor.io/servers/engine.html, I just need to "execute" the pipeline.

I suppose this is more or less like the TestEngine but I am not so familiar with the ktor framework to be sure

Note :

I have already found examples to run one kotlin function per lambda (the best tutorial IMHO being https://aws.amazon.com/fr/blogs/machine-learning/use-amazon-rekognition-to-build-an-end-to-end-serverless-photo-recognition-system/).

The problem is I dont want to manage one lambda per function (I want one microservice per lambda, the microservice being responsible for multiple tightly coupled operations)

like image 727
Christophe Blin Avatar asked Feb 22 '18 09:02

Christophe Blin


1 Answers

After digging a lot more into AWS lambda and the serverless world in general, I've found that using ktor is not what lambda (or more generally function as a service) is useful for.

That is, I wanted to use ktor to group multiple functions in a logical service and to do the "routing" inside this group.

To achieve that in the FaaS world, you must declare one HTTP endpoint for each function.

As this is very tedious to maintain manually, you can use the serverless framework with a proper serverlesss.yml file.

I had this revealation when reading https://github.com/ajurasz/ascii-less-gallery which is a perfect follow of the article I mention in my intial question

like image 63
Christophe Blin Avatar answered Oct 01 '22 21:10

Christophe Blin