Can I deploy i.e `nestjs` app to `aws` using `serv...
# help
k
Can I deploy i.e
nestjs
app to
aws
using
serverless stack cli
?
t
Yep - https://docs.nestjs.com/faq/serverless. Worth reading through this, there are a few tradeoffs but they explain it quite well in the docs. There example uses the serverless framework but the equivalent docs for sst can be found here https://docs.serverless-stack.com/api
k
thanks 😊
t
you can make a single route that catches all the requests
ah assume you just found that and answered your own question 🙂
k
NO. I have no clue what I'm doing actually
t
join the club
k
Copy code
new Api(this, "Api", {
  routes: {
    "$default": "path/to/my/nestjs/app/main",
  },
});
t
yep!
k
And every route become a serverless function?
t
although you may need to use the serverless express package thing
so you have one lambda handling all the requests
k
And then it scales itself based on traffic and jadajada?
Whats the difference if I deploy my server to EC2?
t
ec2 handles concurrent requests better and doesn’t have issues with coldstarts as your application gets large
but you have to pay a fixed monthly cost
where as lambda you pay per user request
for nestJS tbh I’d recommend a container services like fly.io
k
Actually I just watched a video on youtube deploying nestjs app on fly. Can you explain me how fly is different from EC2?
t
Fly deploys your application to a globally distributed network of firecracker vm’s. Firecracker is the same VM tech that lambda uses so it scales super well. Differently to lambda fly can handle concurrent requests using nodes async io goodness. It also keeps your application permanently available so it doesn’t need to start up on user request like lambda does.
compared to ec2 you don’t need to manage any machines or operating system stuff, you just give it a container to run
k
Thanks for taking the time to explain this. Sounds cool