Home

Awesome

nextjs-vercel-aws-cdk-example Mentioned in Awesome CDK

Companion project of the article at https://dev.to/vvo/coding-the-jamstack-missing-parts-databases-crons-background-jobs-1bpj

This is a Next.js example coupled with AWS services to provide:

The goal is to have Next.js being deployed on Vercel, with resources being deployed on AWS via AWS Cloud Development Kit. The AWS stack is described and deployed via a single JavaScript file (infra/ExampleStack.js) thanks to AWS CDK's infrastructure as code (IaC) features.

This example provides local tools to replicate the AWS services in development mode.

Requirements

How to use

  1. Fork this repository, add it to your Vercel projects, deploy it
  2. Clone the repository locally and run
yarn
yarn cdk deploy # first run can be long

This will deploy the services to AWS.

  1. Add necessary env variables to your Vercel project:

You need to add SECRET_AWS_ACCESS_KEY_ID, SECRET_AWS_SECRET_ACCESS_KEY and SECRET_AWS_REGION to Vercel, see https://vercel.com/blog/environment-variables-ui on how to do it.

  1. Verify it's working:

You can check in CloudWatch logs at https://console.aws.amazon.com/cloudwatch/home that your functions are called:

Local development

In local development, all you have to do is:

overmind start

By reading the Procfile This will start:

Tips and docs