diff --git a/README.md b/README.md index 0ea07060..24b0b3d7 100644 --- a/README.md +++ b/README.md @@ -344,6 +344,8 @@ module "lambda_at_edge" { }] runtime = "nodejs16.x" handler = "index.handler" + memory_size = 128 + timeout = 3 event_type = "origin-response" include_body = false } diff --git a/README.yaml b/README.yaml index 823d1def..795b7a53 100644 --- a/README.yaml +++ b/README.yaml @@ -355,6 +355,8 @@ usage: |2- }] runtime = "nodejs16.x" handler = "index.handler" + memory_size = 128 + timeout = 3 event_type = "origin-response" include_body = false } diff --git a/examples/complete/lambda-at-edge.tf b/examples/complete/lambda-at-edge.tf index cbdbbe2a..cb11a12a 100644 --- a/examples/complete/lambda-at-edge.tf +++ b/examples/complete/lambda-at-edge.tf @@ -32,6 +32,8 @@ module "lambda_at_edge" { }] runtime = "nodejs16.x" handler = "index.handler" + memory_size = 128 + timeout = 3 event_type = "viewer-request" include_body = false }, @@ -40,6 +42,8 @@ module "lambda_at_edge" { source_dir = "lib" runtime = "nodejs16.x" handler = "index.handler" + memory_size = 128 + timeout = 3 event_type = "viewer-response" include_body = false }, @@ -47,6 +51,8 @@ module "lambda_at_edge" { source_zip = "origin-request.zip" runtime = "nodejs16.x" handler = "index.handler" + memory_size = 128 + timeout = 3 event_type = "origin-request" include_body = false }, @@ -79,6 +85,8 @@ module "lambda_at_edge" { }] runtime = "nodejs16.x" handler = "index.handler" + memory_size = 128 + timeout = 3 event_type = "origin-response" include_body = false } diff --git a/modules/lambda@edge/README.md b/modules/lambda@edge/README.md index 2b838c53..2071c500 100644 --- a/modules/lambda@edge/README.md +++ b/modules/lambda@edge/README.md @@ -73,7 +73,7 @@ module "lambda_at_edge" { | [destruction\_delay](#input\_destruction\_delay) | The delay, in [Golang ParseDuration](https://pkg.go.dev/time#ParseDuration) format, to wait before destroying the Lambda@Edge
functions.

This delay is meant to circumvent Lambda@Edge functions not being immediately deletable following their dissociation from
a CloudFront distribution, since they are replicated to CloudFront Edge servers around the world.

If set to `null`, no delay will be introduced.

By default, the delay is 20 minutes. This is because it takes about 3 minutes to destroy a CloudFront distribution, and
around 15 minutes until the Lambda@Edge function is available for deletion, in most cases.

For more information, see: https://github.com/hashicorp/terraform-provider-aws/issues/1721. | `string` | `"20m"` | no | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no | -| [functions](#input\_functions) | Lambda@Edge functions to create.

The key of this map is the name label of the Lambda@Edge function.

`source.filename` and `source.content` dictate the name and content of the files that will make up the Lambda function
source, respectively.

`runtime` and `handler` correspond to the attributes of the same name in the [lambda\_function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function)
resource.

`event_type` and `include_body` correspond to the attributes of the same name in the [Lambda Function association block
of the cloudfront\_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#lambda-function-association)
resource. |
map(object({
source = list(object({
filename = string
content = string
}))
runtime = string
handler = string
event_type = string
include_body = bool
}))
| n/a | yes | +| [functions](#input\_functions) | Lambda@Edge functions to create.

The key of this map is the name label of the Lambda@Edge function.

`source.filename` and `source.content` dictate the name and content of the files that will make up the Lambda function
source, respectively.

`runtime`, `handler`, `memory_size`, and `timeout` correspond to the attributes of the same name in the [lambda\_function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function)
resource.

`event_type` and `include_body` correspond to the attributes of the same name in the [Lambda Function association block
of the cloudfront\_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#lambda-function-association)
resource. |
map(object({
source = list(object({
filename = string
content = string
}))
runtime = string
handler = string
memory_size = number
timeout = number
event_type = string
include_body = bool
}))
| n/a | yes | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no | diff --git a/modules/lambda@edge/main.tf b/modules/lambda@edge/main.tf index 985ecf7a..c032d434 100644 --- a/modules/lambda@edge/main.tf +++ b/modules/lambda@edge/main.tf @@ -78,6 +78,8 @@ resource "aws_lambda_function" "default" { function_name = module.function_label[each.key].id runtime = each.value.runtime handler = each.value.handler + memory_size = each.value.memory_size + timeout = each.value.timeout role = module.role[each.key].arn filename = each.value.source_zip != null ? data.local_file.lambda_zip[each.key].filename : data.archive_file.lambda_zip[each.key].output_path source_code_hash = each.value.source_zip != null ? sha256(data.local_file.lambda_zip[each.key].content_base64) : data.archive_file.lambda_zip[each.key].output_base64sha256 diff --git a/modules/lambda@edge/variables.tf b/modules/lambda@edge/variables.tf index 83cbaf61..b1a529f0 100644 --- a/modules/lambda@edge/variables.tf +++ b/modules/lambda@edge/variables.tf @@ -13,8 +13,8 @@ variable "functions" { `source_zip` contains path to zip file with lambda source. - `runtime` and `handler` correspond to the attributes of the same name in the [lambda_function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) - resource. + `runtime`, `handler`, `memory_size` and `timeout` correspond to the attributes of the same name in the [lambda_function](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) + resource. See [here](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-edge-function-restrictions.html) for Lambda@Edge function restrictions. `event_type` and `include_body` correspond to the attributes of the same name in the [Lambda Function association block of the cloudfront_distribution](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution#lambda-function-association) @@ -29,6 +29,8 @@ variable "functions" { source_zip = optional(string) runtime = string handler = string + memory_size = optional(number, 128) + timeout = optional(number, 3) event_type = string include_body = bool }))