Serverless Next.js on AWS with Terraform 1.1

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • goldstack

    Templates and boilerplates for fullstack projects customised to your needs.

  • I originally developed a boilerplate template for Next.js with Bootstrap using Terraform version 0.12 and that has been working well for over a year now (see my original blog post). However, recently AWS announced that changes to their API would require an update of the AWS Terraform Provider. While there is an option to patch an older version of the Terraform provider, I figured that may be as good an excuse as any to update the template to the latest version of Terraform, which is 1.1 as of this writing.

  • terraform

    Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

  • Terraform for better or worse is frequently updated with new versions. Many of these introduce incompatibilities with previous versions that require manual rework of Terraform definitions as well as require updating the local or remote Terraform state.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • nextjs_aws_terraform

    Example project for deploying Next.js to AWS with Terraform using Goldstack template

  • See the configuration for each resource in main.tf.

  • Next.js

    The React Framework

  • Next.js is optimised for deployment to the Vercel platform - which provides a fast and easy way to deploy Next.js projects. Apart from that, Next.js can also be deployed using Docker or a virtual machine that can run Node.js. My aim is to deploy Next.js to AWS using Serverless solutions that are low-cost and easy to scale. Thus, I won't be setting up any EC2 instances or EKS/ECS containers. Instead, I will use the following components:

  • next-optimized-images

    🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).

  • Next.js component is not supported (see Next.js Image loader). Use img instead. The sample project is already set up to use next-optimized-images which can instead be used to serve images.

  • aws-lambda-java-libs

    Official mirror for interface definitions and helper classes for Java code running on the AWS Lambda platform.

  • AWS Lambda: For supporting dynamic routing

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts