You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-7Lines changed: 25 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,28 @@
1
+
<blockquote>
2
+
<palign="center">
3
+
<strong>Note</strong>
4
+
<br />
5
+
The main branch currently contains the atomic deployments alpha preview.
6
+
<br />
7
+
For the lastest stable release, check out the <a href="https://github.com/milliHQ/terraform-aws-next-js/tree/v0.x"><code>v0.x</code> branch</a>.
8
+
</p>
9
+
<palign="center">
10
+
Please see our blog post <a href="https://milli.is/blog/the-road-to-atomic-deployments" target="_blank" rel="noopener">"The road to Atomic Deployments"</a><br />or watch the latest release review for more information:
11
+
<br />
12
+
<br />
13
+
<a aria-label="Terraform Next.js for AWS: First look at the new atomic deployments feature" href="https://www.youtube.com/watch?v=NY3zKnIcLd4" target="_blank" rel="noopener">
> **Note:** The main branch currently contains the atomic deployments alpha preview.
6
-
> For the lastest stable release, please see the [`v0.x` branch](https://github.com/milliHQ/terraform-aws-next-js/tree/v0.x).
7
-
8
26
A zero-config Terraform module for self-hosting Next.js sites serverless on AWS Lambda.
9
27
10
28
## Features
@@ -37,10 +55,10 @@ You should have the following tools installed:
37
55
-[Node.js](https://nodejs.org)
38
56
-[Bash](https://www.gnu.org/software/bash/) & [curl](https://curl.se/) (Should be available by default on many Linux based images or macOS)
39
57
40
-
> Additionally we assume here that you already have a public [Route53 Hosted Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html) associated with your AWS account.
58
+
> **Note:**Additionally we assume here that you already have a public [Route53 Hosted Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html) associated with your AWS account.
41
59
>
42
-
> This is currently a requirement in the preview phase of atomic deployments to enable preview deployments, where each deployment gets a unique subdomain assigned.
43
-
> This will change once atomic deployments become generally available.
60
+
> This is a requirement in the preview phase of atomic deployments, where each deployment gets a unique subdomain assigned.
61
+
> It will change once atomic deployments become generally available.
Copy file name to clipboardExpand all lines: examples/atomic-deployments/README.md
+74-20Lines changed: 74 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,34 @@
2
2
3
3
This example shows how to use the atomic deployments feature with the [Next.js Terraform module for AWS](https://registry.terraform.io/modules/milliHQ/next-js/aws).
4
4
5
+
To learn more about this feature, please see the blog post ["The road to Atomic Deployments"](https://milli.is/blog/the-road-to-atomic-deployments) or watch the release review: [First look at the new atomic deployments feature](https://youtu.be/NY3zKnIcLd4).
6
+
5
7
## Features
6
8
7
-
- Unlimited parallel deployments of Next.js with a single CloudFront distribution
8
-
- Preview deployment subdomains, e.g. `<deployment-id>.example.com`
9
+
-✅ Unlimited parallel deployments of Next.js apps served by a single CloudFront distribution
10
+
-✅ Preview deployment subdomains, e.g. `<deployment-id>.example.com`
9
11
10
-
> **Note:** You can find the full example code on [GitHub](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/atomic-deployments).
12
+
> **Notice:** You can find the full example code on [GitHub](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/atomic-deployments).
11
13
12
-
## Setup
14
+
## How to use
13
15
14
-
Download the files from the example app:
16
+
> **Cost disclaimer**: All resources that are created in your AWS account are designed to be fully serverless.
17
+
> This means it produces **no running costs** until it is actually used (e.g. by deploying a Next.js application or when your app starts receiving requests from the web).
18
+
> Most of the resources created are also eligible for the [AWS always free tier](https://aws.amazon.com/free/).
19
+
>
20
+
> Highest cost factor in this example is the Route 53 hosted zone which can [produce costs of up to $0.50 / month](https://aws.amazon.com/route53/pricing/#Hosted_Zones_and_Records) when creating a new one.
Run [`create-next-app`](https://www.npmjs.com/package/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [yarn](https://classic.yarnpkg.com/en/docs/cli/create/) or [pnpm](https://pnpm.io/cli/create) to bootstrap the example:
> For deploying your apps in the next step you can optionally [create a new IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html) and assign it the policy that you got from the `api_endpoint_access_policy_arn` output.
84
+
> This is a security feature that prevents a full AWS account access during deployments. It only allows access to the internal API, but not to create, destroy or modify any resources in the AWS account directly.
85
+
86
+
### Build
75
87
76
-
Prepare the Next.js application to be deployed with Terraform:
88
+
First, install the [`tf-next`](https://github.com/milliHQ/terraform-aws-next-js/tree/main/packages/tf-next) CLI by running:
89
+
90
+
```
91
+
npm i -g tf-next@canary
92
+
# or
93
+
yarn global add tf-next@canary
94
+
# or
95
+
pnpm add -g tf-next@canary
96
+
```
97
+
98
+
Then prepare your Next.js application for a serverless deployment:
77
99
78
100
```sh
79
-
npm run tf-next
101
+
tf-next build
80
102
```
81
103
82
-
## Deploy
104
+
###Deploy
83
105
84
-
Deploy the previously built Next.js app to the AWS infrastructure:
106
+
Deploy the previously built Next.js app to your AWS infrastructure. For the `--endpoint` flag use the domain you got from the `api_endpoint` output in the previous [Terraform Setup](#terraform-setup) step.
Repeat this until `tf-next deployment ls` shows no more active deployments.
140
+
141
+
2.**Remove the Terraform module**
142
+
To remove the deployment system (with it's global resources like CloudFront, S3 etc.) that were created with Terraform:
143
+
144
+
```
145
+
terraform destroy
146
+
```
147
+
148
+
> **Note:** The destroy command could fail on the first execution since [Lambda@Edge functions cannot be deleted in a synchronous way](https://github.com/hashicorp/terraform-provider-aws/issues/1721). You can workaround this by simply wait ~30 minutes and then run `terraform destroy` again.
Copy file name to clipboardExpand all lines: examples/complete/README.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,11 @@
1
1
# Terraform Next.js complete example
2
2
3
+
> **Warning:** This example is not fully updated for the upcoming `v1.0.0` release.
4
+
> We recommend following the [Atomic Deployments Example](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/atomic-deployments) instead until this example gets an update.
5
+
3
6
This example contains a fully featured Next.js app (Static files, API-Routes, SSR) that can be deployed using the [Terraform Next.js for AWS](https://registry.terraform.io/modules/milliHQ/next-js/aws) module.
4
7
5
-
You can find the full example code on [GitHub](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/complete).
8
+
> **Notice:**You can find the full example code on [GitHub](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/complete).
Copy file name to clipboardExpand all lines: examples/next-image/README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,8 @@
1
1
# Terraform Next.js Image component example
2
2
3
+
> **Warning:** This example is not fully updated for the upcoming `v1.0.0` release.
4
+
> We recommend following the [Atomic Deployments Example](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/atomic-deployments) instead until this example gets an update.
5
+
3
6
This example shows the usage of Next.js together with the `next/image` component.
4
7
You can find the full example code on [GitHub](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/next-image).
Copy file name to clipboardExpand all lines: examples/static/README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,8 @@
1
1
# Terraform Next.js static example
2
2
3
+
> **Warning:** This example is not fully updated for the upcoming `v1.0.0` release.
4
+
> We recommend following the [Atomic Deployments Example](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/atomic-deployments) instead until this example gets an update.
5
+
3
6
This example shows a simple static Next.js app that is deployed to S3 without lambdas using the [Terraform Next.js for AWS](https://registry.terraform.io/modules/milliHQ/next-js/aws) module.
4
7
5
8
You can find the full example code on [GitHub](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/static).
0 commit comments