Skip to content

Commit

Permalink
feat: allow configuration of lambda timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanfreitag committed Aug 20, 2024
1 parent d925fd3 commit c0de9da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ resource "aws_lambda_function" "fsx_health_lambda" {
handler = "index.lambda_handler"
runtime = "python3.12"
memory_size = var.memory_size
timeout = var.timeout
reserved_concurrent_executions = 1
tracing_config {
mode = "Active"
Expand Down
9 changes: 9 additions & 0 deletions tests/defaults.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ run "aws_lambda_function_runtime_default" {
}
}

run "aws_lambda_function_timeout_default" {
command = plan

assert {
condition = aws_lambda_function.fsx_health_lambda.timeout == 30
error_message = "Lambda timeout is not 30 seconds."
}
}

run "eventbridge_default_schedule_expression" {
command = plan

Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ variable "tags" {
default = {
}
}

variable "timeout" {
type = number
description = "The amount of time that Lambda allows a function to run before stopping it. Default is 30 seconds."
default = 30
validation {
condition = var.timeout >= 10 && var.timeout <= 900
error_message = "Timeout must be between 10 and 900."
}
}

0 comments on commit c0de9da

Please sign in to comment.