About

This is an opinated way to launch a Next.js based website on AWS.

This architecture is based on utilizing OpenNext for generation of the site bundles. Refer to OpenNext for more information on what Next.js features it supports.

Installation

1

Copy and paste all code files above into a folder.

Copy the main.tf, variables.tf, outputs.tf, versions.tf, and README.md into a folder (ex. website).

2

Reference the new module as a local or remote module.

module "website" {
  source = "path-to-copied-website-module"

  server_function_config = {
    filename = "server.zip"
  }

  image_optimization_function_config = {
    filename = "image-optimization.zip"
  }

  revlidation_function_config = {
    filename = "revlidation.zip"
  }

  warmer_function_config = {
    filename = "warmer.zip"
  }
}
3

Install dependencies, prep zip bundles dependencies, and deploy!

Install OpenNext and Terraform or OpenTofu dependencies. Then make the correct zip bundles via OpenNext and deploy.

Usage

The options available to can be seen in the variables.tf file as well as in the Next.js module README.

Was this page helpful?