diff --git a/CHANGELOG.md b/CHANGELOG.md index 979b982a..049581ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## [Unreleased] +## [0.11.2] - 2022-01-23 + +### Added + +- Support for response headers policy (`cloudfront_response_headers_policy`) for the internal CloudFront distribution ([#265](https://github.com/milliHQ/terraform-aws-next-js/pull/265), [#268](https://github.com/milliHQ/terraform-aws-next-js/pull/268)) + This also increases the minimum required [Terraform AWS provider](https://github.com/hashicorp/terraform-provider-aws) version from `3.43.0` to `3.64.0`. + +### Fixed + +- Bash script for uploading assets to S3 now uses the standard endpoint and is now compatible with newer AWS regions ([#263](https://github.com/milliHQ/terraform-aws-next-js/pull/263)) +- Components fetched from npm registry now use relative paths that are stored in the Terraform state, which prevents unnecessary deployments ([#261](https://github.com/milliHQ/terraform-aws-next-js/pull/261)) + ## [0.11.1] - 2022-01-15 ### Fixed diff --git a/README.md b/README.md index cc5a8db2..0b24987b 100644 --- a/README.md +++ b/README.md @@ -199,13 +199,13 @@ You can create a `.terraformignore` in the root of your project and add the foll | Name | Version | |------|---------| | terraform | >= 0.15 | -| aws | >= 3.43.0 | +| aws | >= 3.64.0 | ## Providers | Name | Version | |------|---------| -| aws | >= 3.43.0 | +| aws | >= 3.64.0 | ## Inputs @@ -220,6 +220,7 @@ You can create a `.terraformignore` in the root of your project and add the foll | cloudfront\_minimum\_protocol\_version | The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections. One of SSLv3, TLSv1, TLSv1\_2016, TLSv1.1\_2016, TLSv1.2\_2018 or TLSv1.2\_2019. | `string` | `"TLSv1"` | no | | cloudfront\_origin\_request\_policy | Id of a custom request policy that overrides the default policy (AllViewer). Can be custom or managed. | `string` | `null` | 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\_response\_headers\_policy | Id of a response headers policy. Can be custom or managed. Default is empty. | `string` | `null` | no | | cloudfront\_webacl\_id | An optional webacl2 arn or webacl id to associate with the cloudfront distribution | `string` | `null` | no | | create\_image\_optimization | Controls whether resources for image optimization support should be created or not. | `bool` | `true` | no | | debug\_use\_local\_packages | Use locally built packages rather than download them from npm. | `bool` | `false` | no | diff --git a/examples/with-custom-domain/README.md b/examples/with-custom-domain/README.md index bba6027d..915b2435 100644 --- a/examples/with-custom-domain/README.md +++ b/examples/with-custom-domain/README.md @@ -1,7 +1,6 @@ # Terraform Next.js custom domain example This example shows how to use a custom domain with the [Next.js Terraform module for AWS](https://registry.terraform.io/modules/milliHQ/next-js/aws). -The code is based on the [with existing CloudFront distribution example](https://github.com/milliHQ/terraform-aws-next-js/tree/main/examples/with-existing-cloudfront). ## Features diff --git a/main.tf b/main.tf index f9e921a9..d12dd60f 100644 --- a/main.tf +++ b/main.tf @@ -332,8 +332,9 @@ locals { compress = true viewer_protocol_policy = "redirect-to-https" - origin_request_policy_id = var.cloudfront_origin_request_policy != null ? var.cloudfront_origin_request_policy : data.aws_cloudfront_origin_request_policy.managed_all_viewer.id - cache_policy_id = aws_cloudfront_cache_policy.this.id + origin_request_policy_id = var.cloudfront_origin_request_policy != null ? var.cloudfront_origin_request_policy : data.aws_cloudfront_origin_request_policy.managed_all_viewer.id + response_headers_policy_id = var.cloudfront_response_headers_policy + cache_policy_id = aws_cloudfront_cache_policy.this.id lambda_function_association = { event_type = "origin-request" diff --git a/modules/cloudfront-main/main.tf b/modules/cloudfront-main/main.tf index f67df5b5..a4675be5 100644 --- a/modules/cloudfront-main/main.tf +++ b/modules/cloudfront-main/main.tf @@ -70,8 +70,9 @@ resource "aws_cloudfront_distribution" "distribution" { viewer_protocol_policy = default_cache_behavior.value["viewer_protocol_policy"] compress = default_cache_behavior.value["compress"] - origin_request_policy_id = default_cache_behavior.value["origin_request_policy_id"] - cache_policy_id = default_cache_behavior.value["cache_policy_id"] + origin_request_policy_id = default_cache_behavior.value["origin_request_policy_id"] + response_headers_policy_id = default_cache_behavior.value["response_headers_policy_id"] + cache_policy_id = default_cache_behavior.value["cache_policy_id"] dynamic "lambda_function_association" { for_each = [default_cache_behavior.value["lambda_function_association"]] diff --git a/modules/cloudfront-main/versions.tf b/modules/cloudfront-main/versions.tf index 34260e6a..c358271a 100644 --- a/modules/cloudfront-main/versions.tf +++ b/modules/cloudfront-main/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.0" + version = ">= 3.64.0" } } } diff --git a/modules/proxy/main.tf b/modules/proxy/main.tf index c0952799..50356b1d 100644 --- a/modules/proxy/main.tf +++ b/modules/proxy/main.tf @@ -1,6 +1,6 @@ module "proxy_package" { source = "milliHQ/download/npm" - version = "2.0.0" + version = "2.1.0" module_name = "@millihq/terraform-next-proxy" module_version = var.proxy_module_version @@ -26,7 +26,7 @@ module "edge_proxy" { role_permissions_boundary = var.lambda_role_permissions_boundary create_package = false - local_existing_package = module.proxy_package.abs_path + local_existing_package = module.proxy_package.rel_path cloudwatch_logs_retention_in_days = 30 diff --git a/modules/proxy/variables.tf b/modules/proxy/variables.tf index b90513df..6e8c2c50 100644 --- a/modules/proxy/variables.tf +++ b/modules/proxy/variables.tf @@ -4,7 +4,7 @@ variable "proxy_module_version" { type = string - default = "0.11.1" + default = "0.11.2" } variable "lambda_default_runtime" { diff --git a/modules/statics-deploy/main.tf b/modules/statics-deploy/main.tf index abb75e3f..5fe9de3e 100644 --- a/modules/statics-deploy/main.tf +++ b/modules/statics-deploy/main.tf @@ -161,7 +161,7 @@ data "aws_iam_policy_document" "access_sqs_queue" { module "lambda_content" { source = "milliHQ/download/npm" - version = "2.0.0" + version = "2.1.0" module_name = "@millihq/terraform-next-deploy-trigger" module_version = var.deploy_trigger_module_version @@ -185,7 +185,7 @@ module "deploy_trigger" { role_permissions_boundary = var.lambda_role_permissions_boundary create_package = false - local_existing_package = module.lambda_content.abs_path + local_existing_package = module.lambda_content.rel_path # Prevent running concurrently reserved_concurrent_executions = 1 diff --git a/modules/statics-deploy/s3-bash4/lib/s3-common.sh b/modules/statics-deploy/s3-bash4/lib/s3-common.sh index 42e1ee7b..f58ebd32 100644 --- a/modules/statics-deploy/s3-bash4/lib/s3-common.sh +++ b/modules/statics-deploy/s3-bash4/lib/s3-common.sh @@ -187,7 +187,7 @@ convS3RegionToEndpoint() { case "$1" in us-east-1) echo "s3.amazonaws.com" ;; - *) echo s3-${1}.amazonaws.com + *) echo s3.${1}.amazonaws.com ;; esac } diff --git a/modules/statics-deploy/variables.tf b/modules/statics-deploy/variables.tf index 566d252f..c88ab4b3 100644 --- a/modules/statics-deploy/variables.tf +++ b/modules/statics-deploy/variables.tf @@ -4,7 +4,7 @@ variable "static_files_archive" { variable "deploy_trigger_module_version" { type = string - default = "0.11.1" + default = "0.11.2" } variable "expire_static_assets" { diff --git a/variables.tf b/variables.tf index 0b0cf912..b24c4dba 100644 --- a/variables.tf +++ b/variables.tf @@ -128,6 +128,12 @@ variable "cloudfront_origin_request_policy" { default = null } +variable "cloudfront_response_headers_policy" { + description = "Id of a response headers policy. Can be custom or managed. Default is empty." + type = string + default = null +} + variable "cloudfront_cache_key_headers" { description = "Header keys that should be used to calculate the cache key in CloudFront." type = list(string) diff --git a/versions.tf b/versions.tf index b648a82a..791f2145 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.43.0" + version = ">= 3.64.0" configuration_aliases = [aws.global_region] } }