From 23ee6303d58640cb02fe7d71e71fc7960e30f48a Mon Sep 17 00:00:00 2001 From: Heath Snow Date: Thu, 18 Nov 2021 01:27:53 -0800 Subject: [PATCH] feat: Add option to configure concurrent running scale up lambda (#1415) Allow > 1 reserved_concurrent_executions for the scale-up lambda function. This is needed when using a strategy matrix in a workflow. --- README.md | 1 + main.tf | 2 ++ modules/runners/README.md | 1 + modules/runners/scale-up.tf | 2 +- modules/runners/variables.tf | 6 ++++++ variables.tf | 6 ++++++ 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee217a3373..58aef2a7cb 100644 --- a/README.md +++ b/README.md @@ -417,6 +417,7 @@ In case the setup does not work as intended follow the trace of events: | [runners\_scale\_down\_lambda\_timeout](#input\_runners\_scale\_down\_lambda\_timeout) | Time out for the scale down lambda in seconds. | `number` | `60` | no | | [runners\_scale\_up\_lambda\_timeout](#input\_runners\_scale\_up\_lambda\_timeout) | Time out for the scale up lambda in seconds. | `number` | `180` | no | | [scale\_down\_schedule\_expression](#input\_scale\_down\_schedule\_expression) | Scheduler expression to check every x for scale down. | `string` | `"cron(*/5 * * * ? *)"` | no | +| [scale\_up\_reserved\_concurrent\_executions](#input\_scale\_up\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no | | [subnet\_ids](#input\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | n/a | yes | | [syncer\_lambda\_s3\_key](#input\_syncer\_lambda\_s3\_key) | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no | | [syncer\_lambda\_s3\_object\_version](#input\_syncer\_lambda\_s3\_object\_version) | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no | diff --git a/main.tf b/main.tf index cab57a03a3..4c9b3858ec 100644 --- a/main.tf +++ b/main.tf @@ -119,6 +119,8 @@ module "runners" { runner_log_files = var.runner_log_files runner_group_name = var.runner_group_name + scale_up_reserved_concurrent_executions = var.scale_up_reserved_concurrent_executions + instance_profile_path = var.instance_profile_path role_path = var.role_path role_permissions_boundary = var.role_permissions_boundary diff --git a/modules/runners/README.md b/modules/runners/README.md index f8e6eaa5af..fcc9d6b85b 100644 --- a/modules/runners/README.md +++ b/modules/runners/README.md @@ -156,6 +156,7 @@ No modules. | [s3\_bucket\_runner\_binaries](#input\_s3\_bucket\_runner\_binaries) | n/a |
object({
arn = string
})
| n/a | yes | | [s3\_location\_runner\_binaries](#input\_s3\_location\_runner\_binaries) | S3 location of runner distribution. | `string` | n/a | yes | | [scale\_down\_schedule\_expression](#input\_scale\_down\_schedule\_expression) | Scheduler expression to check every x for scale down. | `string` | `"cron(*/5 * * * ? *)"` | no | +| [scale\_up\_reserved\_concurrent\_executions](#input\_scale\_up\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no | | [sqs\_build\_queue](#input\_sqs\_build\_queue) | SQS queue to consume accepted build events. |
object({
arn = string
})
| n/a | yes | | [subnet\_ids](#input\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | n/a | yes | | [tags](#input\_tags) | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no | diff --git a/modules/runners/scale-up.tf b/modules/runners/scale-up.tf index cb61dde66a..486ce3de9f 100644 --- a/modules/runners/scale-up.tf +++ b/modules/runners/scale-up.tf @@ -9,7 +9,7 @@ resource "aws_lambda_function" "scale_up" { handler = "index.scaleUpHandler" runtime = "nodejs14.x" timeout = var.lambda_timeout_scale_up - reserved_concurrent_executions = 1 + reserved_concurrent_executions = var.scale_up_reserved_concurrent_executions memory_size = 512 tags = local.tags diff --git a/modules/runners/variables.tf b/modules/runners/variables.tf index 5e1e795385..fd72a55710 100644 --- a/modules/runners/variables.tf +++ b/modules/runners/variables.tf @@ -163,6 +163,12 @@ variable "lambda_timeout_scale_down" { default = 60 } +variable "scale_up_reserved_concurrent_executions" { + description = "Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations." + type = number + default = 1 +} + variable "lambda_timeout_scale_up" { description = "Time out for the scale up lambda in seconds." type = number diff --git a/variables.tf b/variables.tf index 778bcdadf7..21b8ed3dea 100644 --- a/variables.tf +++ b/variables.tf @@ -69,6 +69,12 @@ variable "runner_group_name" { default = "Default" } +variable "scale_up_reserved_concurrent_executions" { + description = "Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations." + type = number + default = 1 +} + variable "webhook_lambda_zip" { description = "File location of the webhook lambda zip file." type = string