diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 474e78a..42f08f0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,4 @@ updates: interval: 'daily' allow: - dependency-name: 'next' + - dependency-name: 'sharp' diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a655c9c..ddb2c17 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,7 +25,7 @@ jobs: - name: Build run: | yarn --frozen-lockfile --cache-folder .yarn - yarn workspace @dealmore/tf-next-image-optimization build + yarn workspace @millihq/tf-next-image-optimization build - name: Artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/tf-docs.yml b/.github/workflows/tf-docs.yml index f0c131d..2bac40b 100644 --- a/.github/workflows/tf-docs.yml +++ b/.github/workflows/tf-docs.yml @@ -14,8 +14,9 @@ jobs: steps: - uses: actions/checkout@v2 - name: Update Terraform docs in README - uses: Dirrk/terraform-docs@v1.0.8 + uses: terraform-docs/gh-actions@v0.10.0 with: - tf_docs_output_file: README.md - tf_docs_git_push: 'true' - tf_docs_git_commit_message: 'docs: Update Terraform docs' + config-file: '.terraform-docs.yml' + output-file: README.md + git-push: 'true' + git-commit-message: 'docs: Update Terraform docs' diff --git a/.terraform-docs.yml b/.terraform-docs.yml new file mode 100644 index 0000000..a825e1e --- /dev/null +++ b/.terraform-docs.yml @@ -0,0 +1,10 @@ +formatter: 'markdown table' + +sections: + hide: + - 'data-sources' + - 'modules' + - 'resources' + +settings: + anchor: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 1983a5c..22273c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,71 +1,95 @@ # Changelog -## 10.0.1 (July 06, 2021) +## 11.1.0 (August 30, 2021) -- Uses Image Optimizer module of [Next.js 11.0.1](https://github.com/vercel/next.js/releases/tag/v11.0.1) ([#49](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/49)) +⚠️ **Namespace changed** ⚠️ + +We [recently changed](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/61) the namespace of this module from `dealmore` to `milliHQ`. +Make sure to upgrade the source of the module accordingly: + +```diff +module "next_image_optimizer" { +- source = "dealmore/next-js-image-optimization/aws" ++ source = "milliHQ/next-js-image-optimization/aws" +} +``` + +--- + +Beginning with this release we change the engine that is used to optimize the images from squoosh to Sharp. +Sharp has a much better performance and is therefore better suited for the job. +Please read the [Next.js RFC](https://github.com/vercel/next.js/discussions/27073) for more information. + +- Use sharp as image optimization engine ([#51](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/51), [#57](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/57)) +- Fix typo for default image sizes ([#53](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/53), [#56](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/56)) +- Uses Image Optimizer module of [Next.js 11.1.0](https://github.com/vercel/next.js/releases/tag/v11.1.0) ([#54](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/54)) + +## 11.0.1 (July 06, 2021) + +- Uses Image Optimizer module of [Next.js 11.0.1](https://github.com/vercel/next.js/releases/tag/v11.0.1) ([#49](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/49)) ## 11.0.0 (June 15, 2021) The output `cloudfront_origin_image_optimizer` is now deprecated. Use `cloudfront_origin` instead. -- Fixes image optimization for webp format ([#44](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/44)) +- Fixes image optimization for webp format ([#44](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/44)) Thanks to [@vcnc-hex](https://github.com/vcnc-hex) for contributing! -- Uses Image Optimizer module of [Next.js 11.0.0](https://github.com/vercel/next.js/releases/tag/v11.0.0) ([#45](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/45)) -- Add output for cache behavior ([#43](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/43), [#48](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/48)) -- Bump AWS API Gateway Terraform module from 0.11.0 to 1.1.0 ([#47](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/47)) -- Bump AWS Lambda Terraform module from 1.47.0 to 2.4.0 ([#46](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/46)) +- Uses Image Optimizer module of [Next.js 11.0.0](https://github.com/vercel/next.js/releases/tag/v11.0.0) ([#45](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/45)) +- Add output for cache behavior ([#43](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/43), [#48](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/48)) +- Bump AWS API Gateway Terraform module from 0.11.0 to 1.1.0 ([#47](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/47)) +- Bump AWS Lambda Terraform module from 1.47.0 to 2.4.0 ([#46](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/46)) ## 10.2.3 (June 05, 2021) -- Improves caching of processed images by using [CloudFront Origin Shield](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html) ([#2](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/2), [#41](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/41)) -- Uses Image Optimizer module of [Next.js 10.2.3](https://github.com/vercel/next.js/releases/tag/v10.2.3) ([#39](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/39)) +- Improves caching of processed images by using [CloudFront Origin Shield](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html) ([#2](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/2), [#41](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/41)) +- Uses Image Optimizer module of [Next.js 10.2.3](https://github.com/vercel/next.js/releases/tag/v10.2.3) ([#39](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/39)) ## 10.2.2 (May 22, 2021) -- Uses Image Optimizer module of [Next.js 10.2.2](https://github.com/vercel/next.js/releases/tag/v10.2.2) ([#35](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/35)) +- Uses Image Optimizer module of [Next.js 10.2.2](https://github.com/vercel/next.js/releases/tag/v10.2.2) ([#35](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/35)) ## 10.2.1 (May 22, 2021) -- Uses Image Optimizer module of [Next.js 10.2.1](https://github.com/vercel/next.js/releases/tag/v10.2.1) ([#38](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/38)) +- Uses Image Optimizer module of [Next.js 10.2.1](https://github.com/vercel/next.js/releases/tag/v10.2.1) ([#38](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/38)) ## 10.2.0 (May 11, 2021) -- Uses Image Optimizer module of [Next.js 10.2.0](https://github.com/vercel/next.js/releases/tag/v10.2.0) ([#31](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/31)) +- Uses Image Optimizer module of [Next.js 10.2.0](https://github.com/vercel/next.js/releases/tag/v10.2.0) ([#31](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/31)) ## 10.1.3 (May 11, 2021) -- Uses Image Optimizer module of [Next.js 10.1.3](https://github.com/vercel/next.js/releases/tag/v10.1.3) ([#28](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/28)) +- Uses Image Optimizer module of [Next.js 10.1.3](https://github.com/vercel/next.js/releases/tag/v10.1.3) ([#28](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/28)) ## 10.1.2 (May 04, 2021) -- Uses Image Optimizer module of [Next.js 10.1.2](https://github.com/vercel/next.js/releases/tag/v10.1.2) ([#25](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/25)) +- Uses Image Optimizer module of [Next.js 10.1.2](https://github.com/vercel/next.js/releases/tag/v10.1.2) ([#25](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/25)) ## 10.1.1 (May 04, 2021) -- Uses Image Optimizer module of [Next.js 10.1.1](https://github.com/vercel/next.js/releases/tag/v10.1.1) ([#33](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/33)) +- Uses Image Optimizer module of [Next.js 10.1.1](https://github.com/vercel/next.js/releases/tag/v10.1.1) ([#33](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/33)) ## 10.1.0 (May 04, 2021) -- Uses Image Optimizer module of [Next.js 10.1.0](https://github.com/vercel/next.js/releases/tag/v10.1.0) ([#32](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/32)) +- Uses Image Optimizer module of [Next.js 10.1.0](https://github.com/vercel/next.js/releases/tag/v10.1.0) ([#32](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/32)) ## 10.0.9 (April 27, 2021) -- Uses Image Optimizer module of [Next.js 10.0.9](https://github.com/vercel/next.js/releases/tag/v10.0.9) ([#22](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/22)) +- Uses Image Optimizer module of [Next.js 10.0.9](https://github.com/vercel/next.js/releases/tag/v10.0.9) ([#22](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/22)) ## 10.0.8 (April 26, 2021) -- Makes the module compatible with Terraform `0.15` ([#26](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/26), [#29](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/29)) -- Uses Image Optimizer module of [Next.js 10.0.8](https://github.com/vercel/next.js/releases/tag/v10.0.8) ([#19](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/19)) +- Makes the module compatible with Terraform `0.15` ([#26](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/26), [#29](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/29)) +- Uses Image Optimizer module of [Next.js 10.0.8](https://github.com/vercel/next.js/releases/tag/v10.0.8) ([#19](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/19)) ## 10.0.7 (April 01, 2021) -- Uses Image Optimizer module of [Next.js 10.0.7](https://github.com/vercel/next.js/releases/tag/v10.0.7) ([#10](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/10)) +- Uses Image Optimizer module of [Next.js 10.0.7](https://github.com/vercel/next.js/releases/tag/v10.0.7) ([#10](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/10)) ## 10.0.6 (April 01, 2021) -- Uses Image Optimizer module of [Next.js 10.0.6](https://github.com/vercel/next.js/releases/tag/v10.0.6) ([#3](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/3)) -- Bundling of the image optimizer has changed from ncc to nft ([#23](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/23), [#24](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/24)) +- Uses Image Optimizer module of [Next.js 10.0.6](https://github.com/vercel/next.js/releases/tag/v10.0.6) ([#3](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/3)) +- Bundling of the image optimizer has changed from ncc to nft ([#23](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/23), [#24](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/24)) ## 10.0.5 (March 15, 2021) @@ -81,18 +105,18 @@ InvalidArgument: The parameter ForwardedValues cannot be used when a cache polic This is a known bug in the Terraform AWS provider and may requires a manual upgrade in the AWS Console ([terraform-provider-aws#17626](https://github.com/hashicorp/terraform-provider-aws/issues/17626)). -- Fixes wrong response for repeated requests from external source ([#12](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/12), [#13](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/13)) -- Use Request and Cache Policies in CloudFront distribution ([#5](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/5), [#9](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/9)) -- Upgrades Lambda runtime from `nodejs12.x` to `nodejs14.x`. ([#4](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/4), [#8](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/8)) +- Fixes wrong response for repeated requests from external source ([#12](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/12), [#13](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/13)) +- Use Request and Cache Policies in CloudFront distribution ([#5](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/5), [#9](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/9)) +- Upgrades Lambda runtime from `nodejs12.x` to `nodejs14.x`. ([#4](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/4), [#8](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/8)) ## 2.0.1 (March 08, 2021) -- Bump internal module `terraform-aws-modules/apigateway-v2/aws` from `0.8.0` to `0.11.0` ([#16](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/16), [#18](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/18)) +- Bump internal module `terraform-aws-modules/apigateway-v2/aws` from `0.8.0` to `0.11.0` ([#16](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/16), [#18](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/18)) Resolves compatibility issue with newer versions of Terraform. ## 2.0.0 (February 13, 2021) -- Adds support to resize images from a S3 origin ([#7](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/7)) +- Adds support to resize images from a S3 origin ([#7](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/pull/7)) ## 1.0.0 (February 07, 2021) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7cabc1f..971cb06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Contributions are welcome! -As a general advice it is always a good idea to raise an [issue](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues) before creating a new pull request. +As a general advice it is always a good idea to raise an [issue](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues) before creating a new pull request. This ensures that we don't have to reject pull requests that are not aligning with our roadmap and not wasting your valuable time. ## Contribution Prerequisites @@ -27,7 +27,7 @@ For the worker component you should have installed: #### Codestyle -We use a [GitHub Action](https://github.com/dealmore/terraform-aws-next-js-image-optimization/actions/workflows/lint.yml) to make sure that the committed code is properly formatted. +We use a [GitHub Action](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/actions/workflows/lint.yml) to make sure that the committed code is properly formatted. Before submitting a PR, you should make sure that the code is properly formatted. You can do this by running the Terraform [`fmt` command](https://www.terraform.io/docs/cli/commands/fmt.html) in the root of the repository: @@ -42,7 +42,7 @@ After cloning the repository, run `yarn` to fetch its dependencies. #### Codestyle -We use a [GitHub Action](https://github.com/dealmore/terraform-aws-next-js-image-optimization/actions/workflows/lint.yml) to make sure that the committed code is properly formatted. +We use a [GitHub Action](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/actions/workflows/lint.yml) to make sure that the committed code is properly formatted. Before submitting a PR, you should make sure that the code is properly formatted. You can do this by running the `fix:prettier` command from the root of the repository: @@ -59,7 +59,7 @@ The Terraform module is **not** covered by automatic tests. ## Testing Terraform module Since the Terraform module itself is not covered by automatic tests, testing has to be done manually. -The repository contains some examples in the [`examples/*`](https://github.com/dealmore/terraform-aws-next-js-image-optimization/tree/main/examples) folder, that can be used to run a quick acceptance test on your own AWS account. +The repository contains some examples in the [`examples/*`](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples) folder, that can be used to run a quick acceptance test on your own AWS account. You may need to change a few settings in the `main.tf` file in the root of the example. @@ -69,7 +69,7 @@ To use the local development version instead of downloading it from the Terrafor ```diff module "next_image_optimizer" { -- source = "dealmore/next-js-image-optimization/aws" +- source = "milliHQ/next-js-image-optimization/aws" + source = "../.." ... } diff --git a/LICENSE b/LICENSE index ec51210..26e504f 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2021 Felix Haus (DealMore) + Copyright 2021 Felix Haus (milliVolt infrastructure) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index b70777d..373023d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,22 @@ # Terraform Next.js Image Optimization module for AWS -![CI](https://github.com/dealmore/terraform-aws-next-js-image-optimization/workflows/CI/badge.svg) +[![CI](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/actions/workflows/CI.yml/badge.svg)](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/actions/workflows/CI.yml) + +--- + +## ⚠️ **Namespace changed** ⚠️ + +We [recently changed](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/issues/61) the namespace of this module from `dealmore` to `milliHQ`. +Make sure to upgrade the source of the module accordingly: + +```diff +module "next_image_optimizer" { +- source = "dealmore/next-js-image-optimization/aws" ++ source = "milliHQ/next-js-image-optimization/aws" +} +``` + +--- A drop-in [image optimization loader](https://nextjs.org/docs/basic-features/image-optimization#loader) for the Next.js image component `next/image`. @@ -10,7 +26,8 @@ A drop-in [image optimization loader](https://nextjs.org/docs/basic-features/ima - ✅  Terraform `v0.13+` - ✅  Serverless image processing powered by [AWS Lambda](https://aws.amazon.com/lambda/) -- ✅  [Amazon CloudFront](https://aws.amazon.com/cloudfront/) powered image caching +- ✅  Performant optimization using [sharp](https://github.com/lovell/sharp) library +- ✅  Image caching powered by [Amazon CloudFront](https://aws.amazon.com/cloudfront/) - ✅  Two-layer caching with [CloudFront Origin Shield](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html) - ✅  Support for custom [Device Sizes](https://nextjs.org/docs/basic-features/image-optimization#device-sizes) & [Image Sizes](https://nextjs.org/docs/basic-features/image-optimization#image-sizes) @@ -19,7 +36,7 @@ A drop-in [image optimization loader](https://nextjs.org/docs/basic-features/ima The image optimization module is designed as a full stack AWS app. It relies on multiple AWS services and connects them to work as a single application: -![Architecture overview diagram](https://github.com/dealmore/terraform-aws-next-js-image-optimization/blob/main/docs/assets/architecture.png?raw=true) +![Architecture overview diagram](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/blob/main/docs/assets/architecture.png?raw=true) ## Usage @@ -46,7 +63,7 @@ provider "aws" { } module "next_image_optimizer" { - source = "dealmore/next-js-image-optimization/aws" + source = "milliHQ/next-js-image-optimization/aws" next_image_domains = ["example.com", "sub.example.com"] } @@ -95,8 +112,8 @@ Then rebuild and redeploy your Next.js application to make use of the changed co ## Examples -- [Next.js + Vercel](https://github.com/dealmore/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js) - Use the image optimizer together with a Next.js app deployed on Vercel. -- [Existing CloudFront](https://github.com/dealmore/terraform-aws-next-js-image-optimization/tree/main/examples/with-existing-cloudfront) - Embedd the image optimizer in an existing CloudFront distribution. +- [Next.js + Vercel](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js) - Use the image optimizer together with a Next.js app deployed on Vercel. +- [Existing CloudFront](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-existing-cloudfront) - Embedd the image optimizer in an existing CloudFront distribution. @@ -124,7 +141,7 @@ Then rebuild and redeploy your Next.js application to make use of the changed co | cloudfront\_enable\_origin\_shield | Controls whether CloudFront Origin Shield should be enabled on the image optimizer lambdas. | `bool` | `true` | no | | cloudfront\_origin\_id | Override the id for the custom CloudFront id. | `string` | `"tf-next-image-optimizer"` | no | | cloudfront\_origin\_shield\_region | Override the region choosen for the CloudFront origin shield. Use `auto` to automatically determine the optimal region. | `string` | `"auto"` | no | -| cloudfront\_price\_class | Price class for the CloudFront distributions (main & proxy config). One of PriceClass\_All, PriceClass\_200, PriceClass\_100. | `string` | `"PriceClass_100"` | no | +| cloudfront\_price\_class | Price class for the CloudFront distribution. One of PriceClass\_All, PriceClass\_200, PriceClass\_100. | `string` | `"PriceClass_100"` | no | | debug\_use\_local\_packages | (Debug) Use local packages instead of downloading them from npm. | `bool` | `false` | no | | deployment\_name | Identifier for the deployment group (alphanumeric characters, underscores, hyphens, slashes, hash signs and dots are allowed). | `string` | `"tf-next-image"` | no | | lambda\_attach\_policy\_json | Controls whether lambda\_policy\_json should be added to IAM role for Lambda function. | `bool` | `false` | no | @@ -135,7 +152,7 @@ Then rebuild and redeploy your Next.js application to make use of the changed co | 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\_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` | `"11.0.1"` | no | +| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"11.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 | @@ -160,17 +177,17 @@ Then rebuild and redeploy your Next.js application to make use of the changed co We rely internally on the original Next.js image optimizer. So the versioning of the module is aligned with the version of the corresponding Next.js release. -For example the [`v10.0.5`](https://github.com/dealmore/terraform-aws-next-js-image-optimization/releases/tag/v10.0.5) version of this Terraform module uses the image optimizer from the [Next.js 10.0.5 release](https://github.com/vercel/next.js/releases/tag/v10.0.5). +For example the [`v10.0.5`](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/releases/tag/v10.0.5) version of this Terraform module uses the image optimizer from the [Next.js 10.0.5 release](https://github.com/vercel/next.js/releases/tag/v10.0.5). -Please note that we only publish versions `>=10.0.5`, for a full list of available versions see the published versions in the [Terraform Registry](https://registry.terraform.io/modules/dealmore/next-js-image-optimization/aws). +Please note that we only publish versions `>=10.0.5`, for a full list of available versions see the published versions in the [Terraform Registry](https://registry.terraform.io/modules/milliHQ/next-js-image-optimization/aws). ## Contributing Contributions are welcome! -If you want to improve this module, please take a look at our [contributing guide](https://github.com/dealmore/terraform-aws-next-js-image-optimization/blob/main/CONTRIBUTING.md). +If you want to improve this module, please take a look at our [contributing guide](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/blob/main/CONTRIBUTING.md). ## License -Apache-2.0 - see [LICENSE](https://github.com/dealmore/terraform-aws-next-js-image-optimization/blob/main/LICENSE) for details. +Apache-2.0 - see [LICENSE](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/blob/main/LICENSE) for details. > **Note:** All sample projects in [`examples/*`](./examples) are licensed as MIT to comply with the official [Next.js examples](https://github.com/vercel/next.js/tree/canary/examples). diff --git a/examples/with-existing-cloudfront/LICENSE b/examples/with-existing-cloudfront/LICENSE index d47e5e8..ce8d44c 100644 --- a/examples/with-existing-cloudfront/LICENSE +++ b/examples/with-existing-cloudfront/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Felix Haus (Dealmore) +Copyright (c) 2021 Felix Haus (milliVolt infrastructure) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/examples/with-existing-cloudfront/README.md b/examples/with-existing-cloudfront/README.md index a79bfe8..2c29e67 100644 --- a/examples/with-existing-cloudfront/README.md +++ b/examples/with-existing-cloudfront/README.md @@ -1,8 +1,10 @@ # Example with existing CloudFront distribution -This example shows how to integrate the image optimizer into an existing CloudFront distribution (Without creating a new one). +This example shows how to integrate the image optimizer into an existing CloudFront distribution (without creating a new one). -> **Note:** The full example code is available on [GitHub](https://github.com/dealmore/terraform-aws-next-js-image-optimization/tree/main/examples/with-existing-cloudfront) +This can also be useful when you need advanced customization options for the CloudFront distribution, e.g. using a custom domain. + +> **Note:** The full example code is available on [GitHub](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-existing-cloudfront) ## Integration @@ -11,20 +13,20 @@ However when using the module together with an external CloudFront resource, you ```diff module "next_image_optimizer" { - source = "dealmore/next-js-image-optimization/aws" + source = "milliHQ/next-js-image-optimization/aws" + cloudfront_create_distribution = false } ``` -The module has some preconfigured output values (`cloudfront_allowed_query_string_keys`, `cloudfront_origin_request_policy_id` and `cloudfront_cache_policy_id`) that make it easy to integrate the module with an existing CloudFront resource. +The module has some preconfigured output values (`cloudfront_cache_behavior`, `cloudfront_allowed_query_string_keys`, `cloudfront_origin_request_policy_id` and `cloudfront_cache_policy_id`) that make it easy to integrate the module with an existing CloudFront resource. ```tf ################# # Image Optimizer ################# module "next_image_optimizer" { - source = "dealmore/next-js-image-optimization/aws" + source = "milliHQ/next-js-image-optimization/aws" # Prevent creation of the internal CloudFront distribution cloudfront_create_distribution = false @@ -43,16 +45,20 @@ resource "aws_cloudfront_distribution" "distribution" { is_ipv6_enabled = true comment = "next-image-optimizer-example-external-cf" - default_cache_behavior { - allowed_methods = ["GET", "HEAD"] - cached_methods = ["GET", "HEAD"] - target_origin_id = module.next_image_optimizer.cloudfront_origin_id + dynamic "default_cache_behavior" { + for_each = [module.next_image_optimizer.cloudfront_cache_behavior] + + content { + allowed_methods = default_cache_behavior.value["allowed_methods"] + cached_methods = default_cache_behavior.value["cached_methods"] + target_origin_id = default_cache_behavior.value["target_origin_id"] - viewer_protocol_policy = "redirect-to-https" - compress = true + viewer_protocol_policy = default_cache_behavior.value["viewer_protocol_policy"] + compress = default_cache_behavior.value["compress"] - origin_request_policy_id = module.next_image_optimizer.cloudfront_origin_request_policy_id - cache_policy_id = module.next_image_optimizer.cloudfront_cache_policy_id + origin_request_policy_id = default_cache_behavior.value["origin_request_policy_id"] + cache_policy_id = default_cache_behavior.value["cache_policy_id"] + } } # This is a generic dynamic to create an origin diff --git a/examples/with-existing-cloudfront/main.tf b/examples/with-existing-cloudfront/main.tf index dcd0531..8bfb68e 100644 --- a/examples/with-existing-cloudfront/main.tf +++ b/examples/with-existing-cloudfront/main.tf @@ -16,7 +16,7 @@ provider "aws" { # Image Optimizer ################# module "next_image_optimizer" { - source = "dealmore/next-js-image-optimization/aws" + source = "milliHQ/next-js-image-optimization/aws" # Prevent creation of the internal CloudFront distribution cloudfront_create_distribution = false diff --git a/examples/with-next-js/LICENSE b/examples/with-next-js/LICENSE index c96253c..a32647f 100644 --- a/examples/with-next-js/LICENSE +++ b/examples/with-next-js/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Felix Haus (Dealmore) +Copyright (c) 2021 Felix Haus (milliVolt infrastructure) Copyright (c) 2021 Vercel, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/examples/with-next-js/README.md b/examples/with-next-js/README.md index 225b218..b89dcf5 100644 --- a/examples/with-next-js/README.md +++ b/examples/with-next-js/README.md @@ -2,7 +2,7 @@ This example shows how to use the image optimizer together with an existing Next.js deployment. -> **Note:** The full example code is available on [GitHub](https://github.com/dealmore/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js) +> **Note:** The full example code is available on [GitHub](https://github.com/milliHQ/terraform-aws-next-js-image-optimization/tree/main/examples/with-next-js) ## 1. Deploy the image optimizer to AWS @@ -27,7 +27,7 @@ provider "aws" { } module "next_image_optimizer" { - source = "dealmore/next-js-image-optimization/aws" + source = "milliHQ/next-js-image-optimization/aws" next_image_domains = ["assets.vercel.com"] } diff --git a/examples/with-next-js/main.tf b/examples/with-next-js/main.tf index 90709ba..56eb3e0 100644 --- a/examples/with-next-js/main.tf +++ b/examples/with-next-js/main.tf @@ -12,7 +12,7 @@ provider "aws" { } module "next_image_optimizer" { - source = "dealmore/next-js-image-optimization/aws" + source = "milliHQ/next-js-image-optimization/aws" next_image_domains = ["assets.vercel.com"] } diff --git a/main.tf b/main.tf index 53c5bb4..c8e2bbd 100644 --- a/main.tf +++ b/main.tf @@ -2,13 +2,14 @@ # Worker Lambda ############### module "lambda_content" { - source = "dealmore/download/npm" - version = "1.0.0" + source = "milliHQ/download/npm" + version = "1.1.0" - module_name = "@dealmore/tf-next-image-optimization" + module_name = "@millihq/tf-next-image-optimization" module_version = var.next_image_version path_to_file = "dist.zip" use_local = var.debug_use_local_packages + local_cwd = path.module } resource "random_id" "function_name" { diff --git a/scripts/bundle.js b/scripts/bundle.js index 6a8829e..c8545c1 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -22,22 +22,6 @@ async function main() { ignore: ['**/aws-sdk/**/*'], }); - // Manually add node_modules/next/node_modules/jest-worker/build/workers/threadChild.js - // This is likely a bug in nft or Next.js codebase because this file is required when the png - // example is processed - fileList.push( - 'node_modules/next/node_modules/jest-worker/build/workers/threadChild.js' - ); - - fileList.push( - ...glob.sync( - 'node_modules/next/dist/next-server/server/lib/squoosh/**/*.{js,wasm}', - { - cwd: workspaceRoot, - } - ) - ); - // Create zip file await new Promise((resolve, reject) => { const outputFile = fs.createWriteStream( diff --git a/variables.tf b/variables.tf index 8700220..46830d0 100644 --- a/variables.tf +++ b/variables.tf @@ -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 = "11.0.1" + default = "11.1.0" } variable "next_image_domains" { @@ -82,7 +82,7 @@ variable "cloudfront_create_distribution" { } variable "cloudfront_price_class" { - description = "Price class for the CloudFront distributions (main & proxy config). One of PriceClass_All, PriceClass_200, PriceClass_100." + description = "Price class for the CloudFront distribution. One of PriceClass_All, PriceClass_200, PriceClass_100." type = string default = "PriceClass_100" }