examples
examples copied to clipboard
Suggested improvements for the Next.js example
Feedback from @filipef101 on the original PR:
Amazing, just sharing my experimentations with this: Notes:
- Not sure if needed the npm install & open next build step, IMO that should be handled by the user or CI before triggering the deployment, or it should be generic, ie "build command".
- Doesn't use/deploy the warmer lambda Did play modifying this to deploy to lambda@edge Notes:
- Doesn't use/deploy the revalidation lambda function
- Doesn't setup cloudwatch (not sure if edge specific or not), terraform examples I've seen do mention something about cloudwatch.
What I've learned about making @edge lambdas, since I couldn't find anything on Pulumi docs, to deploy a lambda to edge the steps are:
- lambda needs to be on us-east-1 region
ie: just deploy everything to us-east-1, or pass the provider only to the edge lambda (didn't try)
const useast1 = new aws.Provider('useast1', { region: 'us-east-1' });
const site = new NextJsSite(_prefixWithAppName('mysite'),
{ path: '../' },
{ provider: useast1 },
);
- adding the lambdaFunctionAssociations on the/a cloudfront behaviour
- where the arn is
.qualifiedArn
- where the arn is
- on the lambda enable "publish" flag
- serverFunction role needs to include edgelambda role:
... Service: ['edgelambda.amazonaws.com', 'lambda.amazonaws.com'] ... - lambda arch needs to be
x86_64 - lambda cant take any env variables. (not sure if there's a use case for this) I only changed the server lambda to run on edge so not sure if image lambda can be deployed to edge as you are adding BUCKET_NAME & BUCKET_KEY_PREFIX env vars.
Looks kind of simple to support edge deployments, the terraform example I've seen does it based on a flag using different settings based on it.
I've looked at https://github.com/RJPearson94/terraform-aws-open-next for context lambda main
How about you create a library for the custom resource? It would quickly become the standard for NextJs + Pulumi, rather than having to copy paste from the example code all the time. I see a NextJs app and its related resources as 1 component, that either exists as a unit or not
How about you create a library for the custom resource? It would quickly become the standard for NextJs + Pulumi, rather than having to copy paste from the example code all the time. I see a NextJs app and its related resources as 1 component, that either exists as a unit or not
Strongly agree with this, could be a huge boost for people to switch over to Pulumi over vercel, sst, railway and flightcontrol if there is a simple imported library with one configuration object and plug and play instead of a big template.
Would also be much easier to contribute to.