Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggested improvements for the Next.js example #1485

Open
cnunciato opened this issue Aug 26, 2023 · 2 comments
Open

Suggested improvements for the Next.js example #1485

cnunciato opened this issue Aug 26, 2023 · 2 comments

Comments

@cnunciato
Copy link
Member

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
  • 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

@expelledboy
Copy link

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

@AlaaZorkane
Copy link

AlaaZorkane commented Dec 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants