From daa340ff8099b91f64b98d3175ca9d7458cddd60 Mon Sep 17 00:00:00 2001 From: Roman Volykh Date: Fri, 19 Dec 2025 12:30:24 +0200 Subject: [PATCH] fix: Specify Lambda concurrent executions --- infra/cmd_poweron.tf | 5 +++-- infra/main.tf | 5 +++-- infra/modules/alerting/telegram.tf | 2 +- infra/modules/alerting/variables.tf | 5 +++++ infra/modules/handler/main.tf | 2 +- infra/modules/handler/variables.tf | 5 +++++ infra/observability.tf | 9 +++++---- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/infra/cmd_poweron.tf b/infra/cmd_poweron.tf index d4c9b8e..7b166e6 100644 --- a/infra/cmd_poweron.tf +++ b/infra/cmd_poweron.tf @@ -9,8 +9,9 @@ module "telegram_bot_queue_cmd_poweron" { module "telegram_bot_cmd_poweron" { source = "./modules/handler" - function_name = "telegram-bot-cmd-poweron" - source_path = "${path.root}/../apps/poweron" + function_name = "telegram-bot-cmd-poweron" + reserved_concurrent_executions = 3 + source_path = "${path.root}/../apps/poweron" sqs_batch_size = 10 sqs_queue_arn = module.telegram_bot_queue_cmd_poweron.sqs_queue_arn diff --git a/infra/main.tf b/infra/main.tf index b8506d8..eb12aa3 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -42,8 +42,9 @@ module "telegram_bot_api" { module "telegram_bot_handler_mux" { source = "./modules/handler" - function_name = "telegram-bot-mux" - source_path = "${path.root}/../apps/mux" + function_name = "telegram-bot-mux" + reserved_concurrent_executions = 3 + source_path = "${path.root}/../apps/mux" sqs_batch_size = 10 sqs_queue_arn = module.telegram_bot_queue_mux.sqs_queue_arn diff --git a/infra/modules/alerting/telegram.tf b/infra/modules/alerting/telegram.tf index edbb6a0..6626daa 100644 --- a/infra/modules/alerting/telegram.tf +++ b/infra/modules/alerting/telegram.tf @@ -7,7 +7,7 @@ resource "aws_lambda_function" "telegram" { runtime = "provided.al2023" timeout = 10 memory_size = 128 - reserved_concurrent_executions = 10 + reserved_concurrent_executions = var.reserved_concurrent_executions environment { variables = { diff --git a/infra/modules/alerting/variables.tf b/infra/modules/alerting/variables.tf index 2e78d85..a2a56e3 100644 --- a/infra/modules/alerting/variables.tf +++ b/infra/modules/alerting/variables.tf @@ -3,6 +3,11 @@ variable "name" { type = string } +variable "reserved_concurrent_executions" { + description = "Reserved concurrent executions for the Lambda function" + type = number +} + variable "emails" { description = "Emails to subscribe to the SNS topic" type = list(string) diff --git a/infra/modules/handler/main.tf b/infra/modules/handler/main.tf index ea2fbb7..15ec303 100644 --- a/infra/modules/handler/main.tf +++ b/infra/modules/handler/main.tf @@ -7,7 +7,7 @@ resource "aws_lambda_function" "this" { runtime = "provided.al2023" timeout = var.timeout memory_size = var.memory_size - reserved_concurrent_executions = 10 + reserved_concurrent_executions = var.reserved_concurrent_executions environment { variables = var.environment_variables diff --git a/infra/modules/handler/variables.tf b/infra/modules/handler/variables.tf index 1812d33..4335c22 100644 --- a/infra/modules/handler/variables.tf +++ b/infra/modules/handler/variables.tf @@ -3,6 +3,11 @@ variable "function_name" { type = string } +variable "reserved_concurrent_executions" { + description = "Reserved concurrent executions for the Lambda function" + type = number +} + variable "source_path" { description = "Path to the directory containing main.go (the module will build the binary and create a ZIP)" type = string diff --git a/infra/observability.tf b/infra/observability.tf index cdc2734..d0710fb 100644 --- a/infra/observability.tf +++ b/infra/observability.tf @@ -35,10 +35,11 @@ resource "aws_cloudwatch_metric_alarm" "non_empty_dlq" { module "telegram_bot_alerting" { source = "./modules/alerting" - name = "telegram-bot-alerting" - emails = var.alerting_emails - telegram_chat_id = var.alerting_telegram_chat_id - ssm_param_telegram_api_token = module.telegram_bot_api_token.name + name = "telegram-bot-alerting" + reserved_concurrent_executions = 2 + emails = var.alerting_emails + telegram_chat_id = var.alerting_telegram_chat_id + ssm_param_telegram_api_token = module.telegram_bot_api_token.name role_policies = [ // policy 0 [