AWS CDK (Cloud Development Kit) makes it possible to write infrastructure in
Cloudformation. The tool is growing in popularity and so it seems fitting to
enable Next.js users to be able to deploy their apps using it. The
NextJSLambdaEdge construct will provision the same infrastructure as the
It's simple to include the Next.js construct in your app, the following will deploy your Next app using a Cloudfront domain:
To deploy your stack, use the
cdk CLI as normal.
Adding a Custom Domain
Now you've deployed your app, you'll likely want to add a custom domain:
serverlessBuildOutDir- the output directory of the
domain?: Object- if you'd like to add a custom domain, provide the following three fields on the
memory?: number | Record<string, number>- configure memory on all lambdas or individually.
timeout?: number | Record<string, number>- configure timeout on all lambdas or individually.
name?: string | Record<string, string>- configure the name of all lambdas or individually.
runtime?: lambda.Runtime | Record<string, lambda.Runtime>- configure the runtime of all lambdas or individually.
withLogging?: boolean- set debug logging on the lambda.
s3Props?: Partial<BucketProps>- pass custom s3 props
whiteListedCookies?: string- provide a list of cookies to forward to the CloudFront origin.
defaultBehavior?: Partial<cloudfront.Behaviour>- provide overrides for the default behavior
behaviours?: Array<cloudfront.Behaviour>- an array of Cloudfront distribution behaviours.
invalidationPaths?: string- an array of invalidation paths, by default we invalidate all pages found in manifest
cachePolicyName?: Object: configure the name given to the cache policies