diff --git a/infrastructure/terraform/lambda/_template/main.tf b/infrastructure/terraform/lambda/_template/main.tf index 81b1c7f1..1cd63ffe 100644 --- a/infrastructure/terraform/lambda/_template/main.tf +++ b/infrastructure/terraform/lambda/_template/main.tf @@ -36,6 +36,8 @@ module "lambda" { # Optional: Set maximum_concurrency to limit concurrent SQS-triggered invocations (2-1000) maximum_concurrency = var.maximum_concurrency + reserved_concurrent_executions = var.reserved_concurrent_executions + batch_size = var.batch_size environment = { diff --git a/infrastructure/terraform/lambda/_template/variables.tf b/infrastructure/terraform/lambda/_template/variables.tf index 0a3092ee..daaa0b7c 100644 --- a/infrastructure/terraform/lambda/_template/variables.tf +++ b/infrastructure/terraform/lambda/_template/variables.tf @@ -23,6 +23,12 @@ variable "maximum_concurrency" { description = "Maximum number of concurrent Lambda invocations from SQS (2-1000). null = no limit." } +variable "reserved_concurrent_executions" { + type = number + default = -1 + description = "Reserved concurrency for the Lambda function. -1 = unreserved. 1+ = hard limit across all triggers." +} + variable "batch_size" { type = number default = 1 diff --git a/infrastructure/terraform/lambda/pashub_to_ara/main.tf b/infrastructure/terraform/lambda/pashub_to_ara/main.tf index 0c652dc4..ae719a99 100644 --- a/infrastructure/terraform/lambda/pashub_to_ara/main.tf +++ b/infrastructure/terraform/lambda/pashub_to_ara/main.tf @@ -26,6 +26,8 @@ module "lambda" { # Optional: Set maximum_concurrency to limit concurrent SQS-triggered invocations (2-1000) maximum_concurrency = var.maximum_concurrency + reserved_concurrent_executions = var.reserved_concurrent_executions + batch_size = var.batch_size environment = { diff --git a/infrastructure/terraform/lambda/pashub_to_ara/variables.tf b/infrastructure/terraform/lambda/pashub_to_ara/variables.tf index f16b41ac..e68a26b6 100644 --- a/infrastructure/terraform/lambda/pashub_to_ara/variables.tf +++ b/infrastructure/terraform/lambda/pashub_to_ara/variables.tf @@ -23,6 +23,12 @@ variable "maximum_concurrency" { description = "Maximum number of concurrent Lambda invocations from SQS (2-1000). null = no limit." } +variable "reserved_concurrent_executions" { + type = number + default = 1 + description = "Reserved concurrency. Defaults to 1 to prevent concurrent Playwright browser collisions." +} + variable "batch_size" { type = number default = 1 diff --git a/infrastructure/terraform/modules/lambda_service/main.tf b/infrastructure/terraform/modules/lambda_service/main.tf index 8a159db1..3250110b 100644 --- a/infrastructure/terraform/modules/lambda_service/main.tf +++ b/infrastructure/terraform/modules/lambda_service/main.tf @@ -9,6 +9,8 @@ resource "aws_lambda_function" "this" { memory_size = var.memory_size publish = true + reserved_concurrent_executions = var.reserved_concurrent_executions + environment { variables = var.environment } diff --git a/infrastructure/terraform/modules/lambda_service/variables.tf b/infrastructure/terraform/modules/lambda_service/variables.tf index 43def6ad..46241f30 100644 --- a/infrastructure/terraform/modules/lambda_service/variables.tf +++ b/infrastructure/terraform/modules/lambda_service/variables.tf @@ -16,3 +16,9 @@ variable "environment" { type = map(string) default = {} } + +variable "reserved_concurrent_executions" { + type = number + default = -1 + description = "Reserved concurrency for the Lambda function. -1 = unreserved (default). 0 = throttle all. 1+ = hard limit." +} diff --git a/infrastructure/terraform/modules/lambda_with_sqs/main.tf b/infrastructure/terraform/modules/lambda_with_sqs/main.tf index 35626487..97f86793 100644 --- a/infrastructure/terraform/modules/lambda_with_sqs/main.tf +++ b/infrastructure/terraform/modules/lambda_with_sqs/main.tf @@ -31,7 +31,8 @@ module "lambda" { timeout = var.timeout memory_size = var.memory_size - environment = var.environment + environment = var.environment + reserved_concurrent_executions = var.reserved_concurrent_executions } ############################################ diff --git a/infrastructure/terraform/modules/lambda_with_sqs/variables.tf b/infrastructure/terraform/modules/lambda_with_sqs/variables.tf index 7c2832d2..90585e92 100644 --- a/infrastructure/terraform/modules/lambda_with_sqs/variables.tf +++ b/infrastructure/terraform/modules/lambda_with_sqs/variables.tf @@ -40,3 +40,9 @@ variable "maximum_concurrency" { default = null description = "Maximum number of concurrent Lambda invocations from SQS. null = no limit." } + +variable "reserved_concurrent_executions" { + type = number + default = -1 + description = "Reserved concurrency for the Lambda function. -1 = unreserved. 1 = single-threaded." +}