amplify-hosting
amplify-hosting copied to clipboard
What is the correct way to customize NextJS lambda@edge
Please describe which feature you have a question about?
Amplify to deploy NextJS with SSR, SSG and api's.
Provide additional details
Amplify build the NextJS and delivery it using CloudFront.
They create a Lambda for each of api and SSR routes.
Accessing Lambda console, I can see memory, runtime and other configurations for my lambdas. I can even edit any of then. But in next build/deploy, they are all reset to default again.
How am I suppose to configure how much memory, or what version of runtime, or how long lambda should run before timeout? I can't find anything about it on AWS Docs or panel.
What AWS Services are you utilizing?
- Amplify Console
- To deploy a Next.js 10 app with SSR, SSG and api
Provide additional details e.g. code snippets
Also interested in customizing these settings
I also want to know
Hi @CauanCabral, @andrewgadziksonos, @Leejjon
Unfortunately these settings are not customizable at the moment. We are rolling out a change in the default values to increase the Lamda@Edge execution timeout from 10 seconds to 30 seconds.
If we were to offer customization of these values, how would you like to specify this configuration? Perhaps as environment variables? Or as part of the amplify.yml file? Or as App Settings in the console? We are evaluating options at the moment.
Hi @ferdingler, I would like to define defaults from Console, but any of alternatives are good enough.
Defining timeout default as 30s is really appreciate move.
How about also update default runtime to node 14.x?
I am getting same 10 sec timeout for regeneration lambda, any way to update it ?
How about updating the node version of the lambda edge runtime ? We would like to run the node 16 runtime and it seems to be stuck on an older version ?
I am facing the same issue, we would like to configure the runtime of the lamda edge.
Same here. I don't care if I can customize it via environment variables, or as part of the amplify.yml file, or as App Settings in the console. As long as I can change it. ;)
It kind of sounds like these lambda settings should be in infra as code. I would expect them to be in the amplify branch cloudformation and cdk.
@CauanCabral are you still able to see the Lambdas deployed for your NextJS app?
I've deployed NextJS v12
and v13
and I can't find anything Lambda resources that might be used for API or SSR. I've looked in CloudFormation and Lambda consoles but nothing. 🤔 I'm using Amplify v10.6.2
.
@williamrjribeiro
That's the way the new Amplify platform WEB_COMPUTE works (they manage all resources internally).
Only the old platform WEB_DYNAMIC have CloudFront and associated Lambdas visible.
I don't know if you can choose the WEB_DYNAMIC for new projects.
You can see more about the migration in docs: https://docs.aws.amazon.com/amplify/latest/userguide/update-app-nextjs-version.html
Thanks a lot for the docs link @CauanCabral ! I had missed it and it was quite informative.
Hello everyone (@ferdingler, @CauanCabral, @williamrjribeiro)!
I'm very new to using AWS Amplify, having switched over from Vercel.
I would like to know whether and how one can:
- ~~expose the environment variables to the Lambda handler for API routes~~ (I had to move the
.env
file inside theappRoot
for my monorepo setup) - customize the timeout for the Lambda handlers for the API routes
Any help is really appreciated! Thank you for your time!
I'm so close to having everything work, this is the only blocker 😄
@kelvindecosta I'm sorry but I also don't know. 😓