examples icon indicating copy to clipboard operation
examples copied to clipboard

Provide example of using Pulumi to deploy NextJS app on AWS

Open thesobercoder opened this issue 5 years ago • 5 comments

Please provide an example of how to use Pulumi to deploy NextJS to AWS replicating how deployments work on Vercel infrastructure with edge network.

I'm looking for an example which replicates the same behavior as this component does for serverless.

thesobercoder avatar Aug 28 '20 19:08 thesobercoder

I'm giving this a crack, starting with https://github.com/dealmore/terraform-aws-next-js

vha14 avatar Feb 05 '21 18:02 vha14

@thesobercoder According to this issue, there's a chance that v2 will come closer to what you (and me as well) desire.

tlinhart avatar Apr 18 '21 10:04 tlinhart

A basic example—onto which we'd build later on—might be:

  • Serving static content from CloudFront
  • Deploying all api routes as a single Lambda

In theory, next build provides all things necessary for this to work.

gunar avatar Apr 26 '21 17:04 gunar

for anyone struggling to find the answer to this like I was..I attempted to upload this to an S3 bucket, but struggled due to lack of information.

What worked for me:

  • I ran npm build && npm export which generated the static HTML files for me.
  • Then I ran aws s3 sync ../{folder path}/ s3://$(pulumi stack output bucketName) --acl public-read

blackgirlbytes avatar Oct 03 '21 21:10 blackgirlbytes

I can not find (and trust I have looked) any working example with pulumi. However, I have found a template to start from to begin the process. Scary stuff...

expelledboy avatar Jul 27 '22 12:07 expelledboy

Any updates on this, using Pulumi not any other infra as code provider?

Thanks.

T04435 avatar May 03 '23 11:05 T04435

How critical is the advantage of the Edge deployment vs EC2/ECS + Cloudfront / Cloudflare? It seems like Next changes stuff so often that investing into Edge is not even worth it as much?

DimmKirr avatar Aug 06 '23 20:08 DimmKirr

The PR at https://github.com/pulumi/examples/pull/1475 includes an example of a component that deploys the infrastructure needed to deploy a high-performance Next.js site on AWS using Pulumi. This leverages OpenNext which providers a more robust way to package Next.js builds for AWS (and AWS serverless specifically).

lukehoban avatar Aug 07 '23 17:08 lukehoban