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 Jun 20, 2021
2 parents f494b94 + e35d953 commit b451c91
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 26 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 0.9.1 - (June 20, 2021)

This is a maintenance release which upgrades the image optimizer module to the latest version.
We also changed the behavior of the proxy module so that the default root object in CloudFront is no longer necessary.

No configuration changes should be necessary when upgrading from the `0.9.0` release.

### Terraform module

- Upgrades Proxy component to 0.7.0 ([#139](https://github.com/dealmore/terraform-aws-next-js/issues/139), [#141](https://github.com/dealmore/terraform-aws-next-js/pull/141))
- Upgrades [Terraform Next.js Image Optimization module for AWS](https://github.com/dealmore/terraform-aws-next-js-image-optimization) to `11.x.x` release ([#142](https://github.com/dealmore/terraform-aws-next-js/issues/142), [#144](https://github.com/dealmore/terraform-aws-next-js/pull/144))
The image optimizer Lambda now uses `2048mb` RAM by default (from `1024mb`) to improve resizing speed.
You can change that amount with the newly introduced variable `image_optimization_lambda_memory_size`.
This has no effect on the Lambda functions that serve the Next.js pages or api routes (they remain at `1024mb` by default).
- Bump AWS Lambda Terraform module from 1.47.0 to 2.4.0 ([#145](https://github.com/dealmore/terraform-aws-next-js/pull/145))
- Bump AWS API Gateway Terraform module from 0.11.0 to 1.1.0 ([#146](https://github.com/dealmore/terraform-aws-next-js/pull/146))

## Proxy (0.7.0)

- Fix root route rewrites ([#139](https://github.com/dealmore/terraform-aws-next-js/issues/139), [#141](https://github.com/dealmore/terraform-aws-next-js/pull/141))

## 0.9.0 - (June 15, 2021)

**⚠️ Breaking Changes ⚠️**
Expand Down Expand Up @@ -36,7 +57,7 @@ For more information please see the ["with existing CloudFront"](https://github.
## Proxy (0.6.0)

- Support rewriting to an external URL ([#65](https://github.com/dealmore/terraform-aws-next-js/issues/65), [#120](https://github.com/dealmore/terraform-aws-next-js/pull/120))
- Bump runtime from `nodejs12.x` to `nodejs14.x` ([136](https://github.com/dealmore/terraform-aws-next-js/pull/136))
- Bump runtime from `nodejs12.x` to `nodejs14.x` ([#136](https://github.com/dealmore/terraform-aws-next-js/pull/136))

### Deploy trigger (0.4.0)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ You can create a `.terraformignore` in the root of your project and add the foll
| debug\_use\_local\_packages | Use locally built packages rather than download 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"` | no |
| expire\_static\_assets | Number of days after which static assets from previous deployments should be removed from S3. Set to -1 to disable expiration. | `number` | `30` | no |
| image\_optimization\_lambda\_memory\_size | Amount of memory in MB the worker Lambda Function for image optimization can use. Valid value between 128 MB to 10,240 MB, in 1 MB increments. | `number` | `2048` | no |
| lambda\_attach\_to\_vpc | Set to true if the Lambda functions should be attached to a VPC. Use this setting if VPC resources should be accessed by the Lambda functions. When setting this to true, use vpc\_security\_group\_ids and vpc\_subnet\_ids to specify the VPC networking. Note that attaching to a VPC would introduce a delay on to cold starts | `bool` | `false` | no |
| lambda\_environment\_variables | Map that defines environment variables for the Lambda Functions in Next.js. | `map(string)` | `{}` | no |
| lambda\_memory\_size | Amount of memory in MB a Lambda Function can use at runtime. Valid value between 128 MB to 10,240 MB, in 1 MB increments. | `number` | `1024` | no |
Expand Down
25 changes: 7 additions & 18 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ resource "aws_lambda_permission" "current_version_triggers" {
function_name = random_id.function_name[each.key].hex
principal = "apigateway.amazonaws.com"

source_arn = "${module.api_gateway.this_apigatewayv2_api_execution_arn}/*/*/*"
source_arn = "${module.api_gateway.apigatewayv2_api_execution_arn}/*/*/*"
}

#############
Expand All @@ -125,7 +125,7 @@ locals {

module "api_gateway" {
source = "terraform-aws-modules/apigateway-v2/aws"
version = "0.11.0"
version = "1.1.0"

name = var.deployment_name
description = "Managed by Terraform-next.js"
Expand Down Expand Up @@ -154,7 +154,7 @@ module "next_image" {
count = var.create_image_optimization ? 1 : 0

source = "dealmore/next-js-image-optimization/aws"
version = "~> 10.0.8"
version = ">= 11.0.0"

cloudfront_create_distribution = false

Expand All @@ -170,6 +170,7 @@ module "next_image" {

source_bucket_id = module.statics_deploy.static_bucket_id

lambda_memory_size = var.image_optimization_lambda_memory_size
lambda_attach_policy_json = true
lambda_policy_json = data.aws_iam_policy_document.access_static_deployment.json
lambda_role_permissions_boundary = var.lambda_role_permissions_boundary
Expand Down Expand Up @@ -295,7 +296,7 @@ resource "aws_cloudfront_cache_policy" "this" {
locals {
# CloudFront default root object
################################
cloudfront_default_root_object = "index"
cloudfront_default_root_object = ""

# CloudFront Origins
####################
Expand All @@ -316,7 +317,7 @@ locals {
},
{
name = "x-env-api-endpoint"
value = trimprefix(module.api_gateway.this_apigatewayv2_api_api_endpoint, "https://")
value = trimprefix(module.api_gateway.apigatewayv2_api_api_endpoint, "https://")
}
]
}
Expand Down Expand Up @@ -376,19 +377,7 @@ locals {
}

# next/image behavior
# TODO: Replace with output from https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/43
cloudfront_ordered_cache_behavior_next_image = var.create_image_optimization ? {
path_pattern = "/_next/image*"
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
target_origin_id = module.next_image[0].cloudfront_origin_id

compress = true
viewer_protocol_policy = "redirect-to-https"

origin_request_policy_id = module.next_image[0].cloudfront_origin_request_policy_id
cache_policy_id = module.next_image[0].cloudfront_cache_policy_id
} : null
cloudfront_ordered_cache_behavior_next_image = var.create_image_optimization ? module.next_image[0].cloudfront_cache_behavior : null

# Little hack here to create a dynamic object with different number of attributes
# using filtering: https://www.terraform.io/docs/language/expressions/for.html#filtering-elements
Expand Down
2 changes: 1 addition & 1 deletion modules/proxy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ resource "random_id" "function_name" {

module "edge_proxy" {
source = "terraform-aws-modules/lambda/aws"
version = "1.47.0"
version = "2.4.0"

lambda_at_edge = true

Expand Down
2 changes: 1 addition & 1 deletion modules/proxy/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#############

output "lambda_edge_arn" {
value = module.edge_proxy.this_lambda_function_qualified_arn
value = module.edge_proxy.lambda_function_qualified_arn
}
2 changes: 1 addition & 1 deletion modules/proxy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

variable "proxy_module_version" {
type = string
default = "0.6.0"
default = "0.7.0"
}

variable "lambda_default_runtime" {
Expand Down
8 changes: 4 additions & 4 deletions modules/statics-deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "aws_s3_bucket_notification" "on_create" {
bucket = aws_s3_bucket.static_upload.id

lambda_function {
lambda_function_arn = module.deploy_trigger.this_lambda_function_arn
lambda_function_arn = module.deploy_trigger.lambda_function_arn
events = ["s3:ObjectCreated:*"]
}
}
Expand Down Expand Up @@ -174,7 +174,7 @@ resource "random_id" "function_name" {

module "deploy_trigger" {
source = "terraform-aws-modules/lambda/aws"
version = "1.47.0"
version = "2.4.0"

function_name = random_id.function_name.hex
description = "Managed by Terraform-next.js"
Expand Down Expand Up @@ -307,7 +307,7 @@ data "aws_iam_policy_document" "sqs_queue" {

values = [
aws_sns_topic.this.arn,
module.deploy_trigger.this_lambda_function_arn
module.deploy_trigger.lambda_function_arn
]
}

Expand All @@ -320,7 +320,7 @@ data "aws_iam_policy_document" "sqs_queue" {
}

resources = [
module.deploy_trigger.this_lambda_function_arn,
module.deploy_trigger.lambda_function_arn,
]
}
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ variable "create_image_optimization" {
default = true
}

variable "image_optimization_lambda_memory_size" {
description = "Amount of memory in MB the worker Lambda Function for image optimization can use. Valid value between 128 MB to 10,240 MB, in 1 MB increments."
type = number
default = 2048
}

variable "expire_static_assets" {
description = "Number of days after which static assets from previous deployments should be removed from S3. Set to -1 to disable expiration."
type = number
Expand Down

0 comments on commit b451c91

Please sign in to comment.