Skip to content

Commit 9060d44

Browse files
committed
feat: add timeout and memory size configuration for Lambda warmer function
1 parent 079169a commit 9060d44

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
</p>
2525
<!-- markdownlint-restore -->
2626

27-
28-
2927
## Overview
3028

3129
This module creates a Lambda function that automatically warms up other Lambda functions based on specified tags. It uses EventBridge Scheduler to trigger the warming process at regular intervals.
@@ -50,6 +48,8 @@ module "lambda_warmer" {
5048
prewarm_tag_key = "Project"
5149
prewarm_tag_value = "MyProject"
5250
lambda_schedule_expression = "rate(5 minutes)"
51+
timeout = 60
52+
memory_size = 256
5353
scheduler_max_retry_attempts = 0
5454
invocation_type = "Event"
5555
}
@@ -108,11 +108,13 @@ def lambda_handler(event, context):
108108
|------|-------------|------|---------|
109109
| environment | Current environment, e.g. dev, stage, prod | string | "default" |
110110
| lambda_function_name | Name of the Lambda function used for prewarming | string | "lambda-warmer" |
111-
| lambda_schedule_expression | EventBridge schedule expression for triggering the Lambda warmer | string | "rate(5 minutes)" |
111+
| lambda_schedule_expression | [EventBridge schedule expression](https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html) for triggering the Lambda warmer | string | "rate(5 minutes)" |
112112
| scheduler_max_retry_attempts | Maximum retry attempts for the EventBridge scheduler target | number | 0 |
113+
| timeout | Timeout for the Lambda function in seconds | number | 10 |
114+
| memory_size | Memory size for the Lambda function | number | 128 |
113115
| prewarm_tag_key | The tag key to identify functions that need prewarming | string | "Prewarm" |
114116
| prewarm_tag_value | The expected value of the tag for functions that need prewarming | string | "true" |
115-
| invocation_type | The invocation type of the Lambda Warmer function (Event / RequestResponse) | string | "Event" |
117+
| invocation_type | The [invocation type](https://docs.aws.amazon.com/lambda/latest/api/API_Invoke.html#API_Invoke_RequestSyntax) of the Lambda Warmer function (Event / RequestResponse) | string | "Event" |
116118

117119
## Outputs
118120

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ resource "aws_lambda_function" "lambda_warmer" {
116116
runtime = "python3.11"
117117
source_code_hash = filebase64sha256(data.archive_file.lambda_zip.output_path)
118118
description = "Lambda function to warm other functions"
119-
timeout = 60
119+
timeout = var.timeout
120+
memory_size = var.memory_size
120121

121122
environment {
122123
variables = {

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ variable "lambda_schedule_expression" {
2121
default = "rate(5 minutes)"
2222
}
2323

24+
variable "timeout" {
25+
description = "Timeout for the Lambda warmer function."
26+
type = number
27+
default = 60
28+
}
29+
30+
variable "memory_size" {
31+
description = "Memory size for the Lambda warmer function."
32+
type = number
33+
default = 128
34+
}
35+
2436
variable "scheduler_max_retry_attempts" {
2537
description = "Maximum retry attempts for the EventBridge scheduler target."
2638
type = number

0 commit comments

Comments
 (0)