AWS Lambdas are one of the best serverless options, and they include a very nice free tier.
server.jsfile generated by
npx frontity buildshould be ready to be uploaded to AWS without requiring any extra modification.
It should work with the amazon domain (https://ov8mwmh2xa.execute-api.us-east-1.amazonaws.com/latest) as well as a custom domain (https://domain.com).
This is especially tricky because the URLs of the amazon domain contain a folder that needs to be stripped out:
But when people switch to a custom domain, that folder diappears:
It should also work on other services that also use the AWS Lambdas, like Netlify Functions.
We should avoid the need for external tools, like the
serverlessframework. It should work by default.
Nice to have:
- It would be really nice if we could provide some easy instructions to upload the Lambda after the deployment, maybe using a simple npm CLI like this or this.
We could use this library https://github.com/dougmoscrop/serverless-http but I think I’m more in favor of using the official Express library directly (https://github.com/awslabs/aws-serverless-express) because it has better support. How to use it with Koa is explained in this other library: https://github.com/compwright/aws-serverless-koa/blob/master/index.js
There is more information on the Deploy to AWS Lambda? thread.
Especially, I did some research on how to solve the amazon domain vs custom domain problem in this post.
I have made a small video to explain how the code for the
server.js file is generated: