https://github.com/flexstack/nextjs-cdk
An example for deploying a Next.js app to AWS Fargate with AWS CDK
https://github.com/flexstack/nextjs-cdk
aws-apigateway aws-cdk aws-cloudfront aws-fargate cdk cdk-examples nextjs nextjs-cdk nextjs-examples
Last synced: 15 days ago
JSON representation
An example for deploying a Next.js app to AWS Fargate with AWS CDK
- Host: GitHub
- URL: https://github.com/flexstack/nextjs-cdk
- Owner: flexstack
- License: mit
- Created: 2024-07-31T20:22:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-31T22:20:53.000Z (over 1 year ago)
- Last Synced: 2025-02-03T12:23:12.958Z (12 months ago)
- Topics: aws-apigateway, aws-cdk, aws-cloudfront, aws-fargate, cdk, cdk-examples, nextjs, nextjs-cdk, nextjs-examples
- Language: JavaScript
- Homepage: https://flexstack.com/docs/languages-and-frameworks/how-to-deploy-next-js-to-aws
- Size: 382 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Next.js on AWS Fargate with AWS CDK

## Architecture
See the [CDK code](./infra/bin/infra.ts) for the full architecture.
- A VPC with public, private, private isolated subnets
- An ECS cluster with a Fargate service
- A Route 53 private hosted zone for the ECS service (AWS CloudMap/Service Discovery)
- API Gateway w/ VPC Link Integration to the ECS service using the private DNS name
- An ECS task definition with a container that runs the Next.js app
- A CloudFront distribution with an API Gateway origin
## Deploy to AWS with CDK
First, you need to install [aws-cdk](https://www.npmjs.com/package/aws-cdk).
```bash
cd infra
npm install
# Bootstrap the CDK environment
cdk bootstrap --qualifier nextjscdk
# Deploy the stack
cdk deploy --all
```