Skip to content

Commit

Permalink
Merge commit 'b7e08447762fa157ee440c806d81f962a55ff9dd' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 4, 2022
2 parents 2658756 + b7e0844 commit 9f57ec2
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## [12.1.0] - 2022-04-04

- Ensure compatibility with AWS Provider Version 4 ([#119](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/119), [#120](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/120))
- Uses Image Optimizer module of [Next.js 12.1.0](https://github.com/vercel/next.js/releases/tag/v12.1.0) ([#123](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/123))
- Adds option to enable SVG support ([#124](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/124))

## [12.0.10] - 2022-03-29

- Updates sharp from `v0.30.1` to [`v0.30.3`](https://github.com/lovell/sharp/releases/tag/v0.30.3) ([#115](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/115))
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down Expand Up @@ -111,13 +111,13 @@ Then rebuild and redeploy your Next.js application to make use of the changed co
| Name | Version |
|------|---------|
| terraform | >= 0.13 |
| aws | >= 3.43.0 |
| aws | >= 4.8 |

## Providers

| Name | Version |
|------|---------|
| aws | >= 3.43.0 |
| aws | >= 4.8 |

## Inputs

Expand All @@ -136,11 +136,13 @@ Then rebuild and redeploy your Next.js application to make use of the changed co
| lambda\_role\_permissions\_boundary | ARN of IAM policy that scopes aws\_iam\_role access for the lambda. | `string` | `null` | no |
| lambda\_timeout | Max amount of time the worker Lambda Function has to return a response in seconds. Should not be more than 30 (Limited by API Gateway). | `number` | `30` | no |
| next\_image\_base\_origin | Base URL where requests for absolute image paths should be resolved to. Should not have a trailing slash. | `string` | `null` | no |
| next\_image\_content\_security\_policy | Set the value of the Content-Security-Policy header in the response of the image optimizer. | `string` | `null` | no |
| next\_image\_dangerously\_allow\_SVG | Enable the optimization of SVG images. | `bool` | `false` | no |
| next\_image\_device\_sizes | Allowed device sizes that should be used for image optimization. | `list(number)` | `null` | no |
| next\_image\_domains | Allowed origin domains that can be used for fetching images. | `list(string)` | `[]` | no |
| next\_image\_formats | If the Accept head matches more than one of the configured formats, the first match in the array is used. Therefore, the array order matters. If there is no match, the Image Optimization API will fallback to the original image's format. | `list(string)` | <pre>[<br> "image/webp"<br>]</pre> | no |
| next\_image\_image\_sizes | Allowed image sizes that should be used for image optimization. | `list(number)` | `null` | no |
| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"12.0.10"` | no |
| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"12.1.0"` | no |
| source\_bucket\_id | When your static files are deployed to a Bucket (e.g. with Terraform Next.js) the optimizer can pull the source from the bucket rather than over the internet. | `string` | `null` | no |
| tags | Tag metadata to label AWS resources that support tags. | `map(string)` | `{}` | no |

Expand Down
Binary file modified docs/assets/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/with-existing-cloudfront/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
31 changes: 23 additions & 8 deletions examples/with-next-js-export/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down Expand Up @@ -40,23 +40,38 @@ module "next_image_optimizer" {
###########
resource "aws_s3_bucket" "website_bucket" {
bucket_prefix = var.deployment_name
acl = "public-read"
force_destroy = true

tags = {
Name = var.deployment_name
}
}

resource "aws_s3_bucket_acl" "website_bucket" {
bucket = aws_s3_bucket.website_bucket.id
acl = "public-read"
}

resource "aws_s3_bucket_cors_configuration" "website_bucket" {
bucket = aws_s3_bucket.website_bucket.id

cors_rule {
allowed_headers = ["Authorization", "Content-Length"]
allowed_methods = ["GET", "POST"]
allowed_origins = ["*"]
max_age_seconds = 3000
}
}

website {
index_document = "index.html"
error_document = "404/index.html"
resource "aws_s3_bucket_website_configuration" "website_bucket" {
bucket = aws_s3_bucket.website_bucket.id

index_document {
suffix = "index.html"
}

tags = {
Name = var.deployment_name
error_document {
key = "404/index.html"
}
}

Expand Down Expand Up @@ -106,7 +121,7 @@ resource "aws_cloudfront_distribution" "distribution" {
}

origin {
domain_name = aws_s3_bucket.website_bucket.website_endpoint
domain_name = aws_s3_bucket_website_configuration.website_bucket.website_endpoint
origin_id = "website-bucket"

custom_origin_config {
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
version = "~> 4.0"
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module "lambda_content" {

module "image_optimizer" {
source = "terraform-aws-modules/lambda/aws"
version = "2.17.0"
version = "3.1.0"

function_name = var.deployment_name
description = "Managed by Terraform Next.js image optimizer"
Expand All @@ -26,13 +26,15 @@ module "image_optimizer" {
publish = true

environment_variables = {
NODE_ENV = "production"
TF_NEXTIMAGE_BASE_ORIGIN = var.next_image_base_origin
TF_NEXTIMAGE_DOMAINS = jsonencode(var.next_image_domains)
TF_NEXTIMAGE_DEVICE_SIZES = var.next_image_device_sizes != null ? jsonencode(var.next_image_device_sizes) : null
TF_NEXTIMAGE_FORMATS = jsonencode(var.next_image_formats)
TF_NEXTIMAGE_IMAGE_SIZES = var.next_image_image_sizes != null ? jsonencode(var.next_image_image_sizes) : null
TF_NEXTIMAGE_SOURCE_BUCKET = var.source_bucket_id
NODE_ENV = "production"
TF_NEXTIMAGE_BASE_ORIGIN = var.next_image_base_origin
TF_NEXTIMAGE_DOMAINS = jsonencode(var.next_image_domains)
TF_NEXTIMAGE_DEVICE_SIZES = var.next_image_device_sizes != null ? jsonencode(var.next_image_device_sizes) : null
TF_NEXTIMAGE_FORMATS = jsonencode(var.next_image_formats)
TF_NEXTIMAGE_IMAGE_SIZES = var.next_image_image_sizes != null ? jsonencode(var.next_image_image_sizes) : null
TF_NEXTIMAGE_DANGEROUSLY_ALLOW_SVG = var.next_image_dangerously_allow_SVG ? jsonencode(var.next_image_dangerously_allow_SVG) : null
TF_NEXTIMAGE_CONTENT_SECURITY_POLICY = var.next_image_content_security_policy != null ? jsonencode(var.next_image_content_security_policy) : null
TF_NEXTIMAGE_SOURCE_BUCKET = var.source_bucket_id
}

create_package = false
Expand Down
14 changes: 13 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
variable "next_image_version" {
description = "Next.js version from where you want to use the image optimizer from. Supports semver ranges."
type = string
default = "12.0.10"
default = "12.1.0"
}

variable "next_image_base_origin" {
Expand Down Expand Up @@ -37,6 +37,18 @@ variable "next_image_image_sizes" {
default = null
}

variable "next_image_dangerously_allow_SVG" {
description = "Enable the optimization of SVG images."
type = bool
default = false
}

variable "next_image_content_security_policy" {
description = "Set the value of the Content-Security-Policy header in the response of the image optimizer."
type = string
default = null
}

variable "lambda_memory_size" {
description = "Amount of memory in MB the worker Lambda Function can use. Valid value between 128 MB to 10,240 MB, in 1 MB increments."
type = number
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.43.0"
version = ">= 4.8"
}
}
}

0 comments on commit 9f57ec2

Please sign in to comment.