sladg / nextjs-lambda

Lambda deployments for Nextjs12 & Nextjs13 (standalone). Easy CLI commands to get your standalone Next output to run in AWS Lambda (not @Edge)! Uses CDK in behind and produces code zips importable to Terraform, Serverless, Azure, etc.
MIT License
169 stars 19 forks source link

Adds customization options for API domain and image lambda #67

Closed fabiob closed 1 year ago

fabiob commented 1 year ago

Hi! Thanks for this great tool, it's helping me a lot. Here's my first contribution, I hope you like it.

Proposed changes

Customization of image lambda memory and timeout parameters

My team is currently working on a website in which the users upload very large images, and the image handler is having a hard time optimizing them with the default settings. I've found the perfect settings for my case (60s timeout and 1Gb memory), but I'm pretty sure this should not be the default. Hence my contribution, to allow their customization (both by CLI and the new CdkUtils class).

To avoid repeating the defaults over and over, I've established some constants on the imageLambda.ts file with the default values. Let me know if this is OK.

Customization of the API domain

While the Next.js rewrite support works nicely, it increases the total cost of the deployment since the server API will be charged while the real backend does its work. This gets worse when the backend is also deployed as a lambda function on the same account, as they will consume two concurrent execution quotas.

The new option should allow full customization of the /api origin when using the CdkUtils class, but can also create a simple HttpOrigin with an specified domain using the CLI.

Notes

sladg commented 1 year ago

Perfect! Thank you very much @fabiob!

Changes makes total sense and implementation is flawless to what I would do myself.

To address your notes: