I created a Lambda function that runs an express app. Is it a bad practice at all? And if not, are there any good practices about it to follow that differ from those of a normal Express API running on Docker, for example?
Lambda functions should not run long running processes (like Express API's). They are scripts that run one-off usually for a very short time (talk about milliseconds). If you want to build an API out of Lambda, you should place an API gateway in front of it to manage the HTTP routing.
Better yet, check this framework out:
It's way miles very helpful in crafting lambda based API's.
Why would you create a lambda function for express application instead of deploying it? It doesn't make any sense, web servers need to be deployed.
Lambda functions is useful to do one time tasks, or for things that are purely computational. What exactly does your web server do?
To get a better understanding of AWS Lambda, AWS just released a new white paper which can help you understand lots of the best practices you should apply to AWS Lambda. I just happen to make a youtube video walk through of this white paper here on youtube yesterday so you're in luck.
Organizing what goes into an AWS Lambda function is tricky because how much responsibility you give it will result in different trade offs.
You can have lambda:
The advantage of having a Lambda handle multiple responsibilities is that you reduce cold-starts because you have a function that has more reusability. The more a function does the harder it is to debug, but the opposite could be said that having too many lambda functions you have to connect and orchestrate is hard to work with, though X-Ray and Step Functions on AWS aims to alleviate this pain so you can keep your AWS Lambda functions as isolate in function as possible.
So back to your question, should ExpressJs be used on AWS Lambda? I would personally say no and would also say its a bad-practice because there is functionality which causes you to put too much responsibility into a Lambda function and things that just won't work without some weird manipulation such as routing.