Next.js on AWS
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-ts-nextjscd pulumi-examples/aws-ts-nextjsThis example deploys a Next.js site on AWS using OpenNext.
Deploying the App#
To deploy your app, follow the below steps.
Prerequisites#
Steps#
After cloning this repo, from this working directory, run these commands:
-
Install the required Node.js packages:
Terminal window npm install -
Create a new stack, which is an isolated deployment target for this example:
Terminal window pulumi stack init -
Set the required configuration variables for this program:
Terminal window pulumi config set aws:region us-west-2You can select any AWS region you would like to use.
-
Deploy your application to it’s own dedicated serving infrastructure in AWS.
Terminal window pulumi up -
Most of the infrastructure will deploy within about 30s, but the CloudFront CDN can take 4-5 minutes. After this is complete, a CloudFront URL where your application is served will be shown.
Terminal window Outputs:url: "https://d119mwdwutz4hu.cloudfront.net"Resources:+ 45 createdDuration: 4m14s -
You can open that URL in your browser to see your Next.js demo app.

-
Make changes to the Next.js app in the
demoappfolder, or bring your own Next.js app and point the Pulumi component at it instead. -
Once you’ve finished experimenting, tear down your stack’s resources by destroying and removing it:
Terminal window pulumi destroy --yespulumi stack rm --yes