Skip to content

Commit

Permalink
merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 27, 2021
2 parents 419f41d + df7b4e7 commit 5b31dec
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 137 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.9.0 - (Unreleased)

## tf-next (0.7.0)

- Adds support for yarn workspaces ([#93](https://github.com/dealmore/terraform-aws-next-js/issues/93), [#107](https://github.com/dealmore/terraform-aws-next-js/pull/107))

### Runtime (1.1.0)

- Bump @vercel/nft from 0.9.5 to 0.10.0 ([#112](https://github.com/dealmore/terraform-aws-next-js/pull/112))

## 0.8.1 - (April 27, 2021)

### Terraform module

- Fixes compatibility with Terraform 0.15 ([#115](https://github.com/dealmore/terraform-aws-next-js/issues/115), [#118](https://github.com/dealmore/terraform-aws-next-js/pull/118))
- Bump AWS Lambda Terraform module from 1.34.0 to 1.47.0 ([#117](https://github.com/dealmore/terraform-aws-next-js/pull/117))
- Bump Next.js Image Optimization module from 10.0.5 to 10.0.8 ([#116](https://github.com/dealmore/terraform-aws-next-js/pull/116))

## 0.8.0 - (April 05, 2021)

This release enables Brotli in addition to gzip as default compression method.
Expand Down
59 changes: 36 additions & 23 deletions examples/complete/.gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
# Local .terraform directories
**/.terraform/*
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# .tfstate files
*.tfstate
*.tfstate.*
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# Crash log files
crash.log
# production
/build

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars
# misc
.DS_Store
*.pem

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# Terraform
**/.terraform/*
*.tfstate
*.tfstate.*

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
# tf-next
/.tf-next/
52 changes: 44 additions & 8 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
# Terraform Next.js complete example

Install it and run:
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/dealmore/next-js/aws) module.

You can find the full example code on [GitHub](https://github.com/dealmore/terraform-aws-next-js/tree/main/examples/complete).

## Setup

Download the files from the example app:

```sh
yarn create next-app --example https://github.com/dealmore/terraform-aws-next-js/tree/main/examples/complete my-app

cd my-app
```

## Build

Prepare the Next.js application to be deployed with Terraform:

```sh
# Build
yarn
yarn tf-next
```

# Terraform
cd terraform
terraform init
terraform plan
terraform apply
## Deploy

Use Terraform to deploy the Next.js app to your AWS account:

```sh
# Expose your AWS Access Keys to the current terminal session
# Only needed when running Terraform commands
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

terraform init # Only needed on the first time running Terraform

terraform plan # (Optional) See what resources Terraform will create
terraform apply # Deploy the Next.js app to your AWS account
```

After the deployment was successful, you should see the following output:

```sh
> Apply complete!
>
> Outputs:
>
> cloudfront_domain_name = "<distribution-id>.cloudfront.net"
```

You can now access your Next.js app in the browser under the [https://&lt;distribution-id&gt;.cloudfront.net](https://<distribution-id>.cloudfront.net) domain.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ provider "aws" {
module "tf_next" {
source = "dealmore/next-js/aws"

next_tf_dir = var.next_tf_dir
deployment_name = var.deployment_name
deployment_name = "terraform-next-js-example-complete"

providers = {
aws.global_region = aws.global_region
}

# Uncomment when using in the cloned monorepo for tf-next development
# source = "../../.."
# source = "../.."
# debug_use_local_packages = true
}

output "cloudfront_domain_name" {
value = module.tf_next.cloudfront_domain_name
}
3 changes: 0 additions & 3 deletions examples/complete/terraform/outputs.tf

This file was deleted.

9 changes: 0 additions & 9 deletions examples/complete/terraform/variables.tf

This file was deleted.

59 changes: 36 additions & 23 deletions examples/custom-domain/.gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
# Local .terraform directories
**/.terraform/*
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# .tfstate files
*.tfstate
*.tfstate.*
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# Crash log files
crash.log
# production
/build

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars
# misc
.DS_Store
*.pem

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# Terraform
**/.terraform/*
*.tfstate
*.tfstate.*

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
# tf-next
/.tf-next/
73 changes: 63 additions & 10 deletions examples/custom-domain/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,70 @@
# Terraform Next.js static example
# Terraform Next.js custom domain example

Demonstrates how to use a custom domain with AWS Next.js Terraform module.
This example shows how to use a custom domain with the [Next.js Terraform module for AWS](https://registry.terraform.io/modules/dealmore/next-js/aws).

Install it and run:
You can find the full example code on [GitHub](https://github.com/dealmore/terraform-aws-next-js/tree/main/examples/custom-domain).

## Setup

Download the files from the example app:

```sh
yarn create next-app --example https://github.com/dealmore/terraform-aws-next-js/tree/main/examples/custom-domain my-app

cd my-app
```

## Build

Prepare the Next.js application to be deployed with Terraform:

```sh
# Build
yarn
yarn tf-next
```

## Setting the domain

Open the `main.tf` file in the root of the Next.js app, and change the following:

```tf
# main.tf
...
locals {
# Your custom domain
custom_domain = "example.com"
}
# Terraform
cd terraform
terraform init
terraform plan
terraform apply
...
```

You can change `example.com` to every domain that is associated with Route 53 in your AWS account.

## Deploy

Use Terraform to deploy the Next.js app to your AWS account:

```sh
# Expose your AWS Access Keys to the current terminal session
# Only needed when running Terraform commands
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

terraform init # Only needed on the first time running Terraform

terraform plan # (Optional) See what resources Terraform will create
terraform apply # Deploy the Next.js app to your AWS account
```

After the deployment was successful, you should see the following output:

```sh
> Apply complete!
>
> Outputs:
>
> cloudfront_domain_name = "<distribution-id>.cloudfront.net"
> custom_domain_name = "example.com"
```

You can now access your Next.js app in the browser under the [example.com](https://example.com) or [https://&lt;distribution-id&gt;.cloudfront.net](https://<distribution-id>.cloudfront.net) domain.
2 changes: 1 addition & 1 deletion examples/custom-domain/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module "cloudfront_cert" {
module "tf_next" {
source = "dealmore/next-js/aws"

deployment_name = "custom-domain-example"
deployment_name = "terraform-next-js-example-custom-domain"

# You can also attach multiple domains here since it accepts an array
# Keep in mind that `domain_names` & `domain_zone_names` should always
Expand Down
2 changes: 1 addition & 1 deletion examples/next-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ terraform plan # (Optional) See what resources Terraform will create
terraform apply # Deploy the Next.js app to your AWS account
```

After the deployent was successful, you should see the following output:
After the deployment was successful, you should see the following output:

```sh
> Apply complete!
Expand Down
Loading

0 comments on commit 5b31dec

Please sign in to comment.