More Premium Hugo Themes Premium Nextjs Themes

Terraform Aws Next Js

Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.

Terraform Aws Next Js

Terraform module for building and deploying Next.js apps to AWS. Supports SSR (Lambda), Static (S3) and API (Lambda) pages.

Author Avatar Theme by millihq
Github Stars Github Stars: 1480
Last Commit Last Commit: Aug 21, 2022 -
First Commit Created: Aug 27, 2024 -
default image

Overview

The Terraform Next.js module for AWS is a zero-config Terraform module designed for self-hosting Next.js sites serverless on AWS Lambda. This module supports various features like unlimited parallel deployments of Next.js apps, support for different types of pages (static, SSG, Lambda, and API pages), automatic expiration of old static assets, rewrites & redirects, and image optimization support.

Features

  • Supports any version of Next.js
  • Terraform v0.15+
  • Unlimited parallel deployments of Next.js apps (atomic deployments)
  • Static, SSG, Lambda, and API pages (with dynamic routes)
  • Automatic expiration of old static assets
  • Rewrites & Redirects
  • Image Component & Image Optimization support
  • Incremental Static Regeneration (under development)
  • Middleware (Not supported by Lambda@Edge / CloudFront functions) (planned)

Installation

  1. Prerequisites: Make sure you have Terraform, Node.js, Bash, and curl installed, and a public Route53 Hosted Zone associated with your AWS account.
  2. Setup the Next.js Terraform module:
    • Create a new main.tf file in an empty folder or existing Terraform stack.
    • Run commands to create resources in your AWS account.
    • Utilize api_endpoint for creating new deployments.
    • Use api_endpoint_access_policy_arn to create new users with restricted access.
  3. Deploy a Next.js App:
    • Install the CLI tool tf-next.
    • Build the Next.js app using tf-next build.
    • Deploy the app with tf-next deploy.

Summary

The Terraform Next.js module for AWS provides a convenient way to host Next.js sites on AWS Lambda with various features like support for different page types, automatic asset expiration, and image optimization. By following the installation guide, users can easily set up the Terraform stack and deploy their Next.js apps using the CLI tool provided. This module simplifies the process of managing and hosting Next.js applications on AWS.