Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flexstack/nextjs-terraform
An example for deploying a Next.js app to AWS with Terraform
https://github.com/flexstack/nextjs-terraform
api-gateway aws-fargate nextjs nextjs-aws nextjs-template nextjs14 terraform terraform-aws terraform-example terraform-examples terraform-template
Last synced: 11 days ago
JSON representation
An example for deploying a Next.js app to AWS with Terraform
- Host: GitHub
- URL: https://github.com/flexstack/nextjs-terraform
- Owner: flexstack
- License: mit
- Created: 2024-07-31T17:25:54.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-31T20:21:10.000Z (4 months ago)
- Last Synced: 2024-08-01T00:21:04.089Z (4 months ago)
- Topics: api-gateway, aws-fargate, nextjs, nextjs-aws, nextjs-template, nextjs14, terraform, terraform-aws, terraform-example, terraform-examples, terraform-template
- Language: HCL
- Homepage: https://flexstack.com/docs/languages-and-frameworks/how-to-deploy-next-js-to-aws
- Size: 375 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 Terraform
![Preview](./.readme/cloudfront-nextjs.png)## Architecture
See the [Terraform code](./infra/main.tf) 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 Terraform
First, you need to install Terraform. You can download it from [here](https://www.terraform.io/downloads.html). You'll
also need Docker and the AWS CLI installed and configured with your AWS credentials.```bash
cd infra
# Initialize the Terraform providers
terraform init
# See the changes that will be applied
terraform plan
# Apply the changes to your default AWS profile
terraform apply
```You can also use a different AWS profile by setting the `TF_VAR_AWS_PROFILE` environment variable.
```bash
TF_VAR_AWS_PROFILE=my-profile terraform apply
```