Skip to content

Commit 76a572a

Browse files
fix(runner): handle long prefixes in pool scheduler and IAM resource names (#5139)
The pool module's `aws_scheduler_schedule_group` and `aws_iam_role` for the scheduler both use `name_prefix`, which has a 38-character limit (64 max name minus 26 for Terraform's random suffix). When the module prefix is long — for example a multi-runner prefix like `self-hosted-linux-ubuntu2404-x64-2cpu-8gb` — the combined `${prefix}-pool` exceeds 38 characters and Terraform fails. For long prefixes, the name is now truncated with an md5 hash suffix to stay within limits, matching the existing pattern used elsewhere in the module. Existing deployments with short prefixes see no resource changes. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b738b86 commit 76a572a

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

modules/runners/pool/main.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
locals {
2+
pool_name_prefix = (
3+
length("${var.config.prefix}-pool") <= 38
4+
? "${var.config.prefix}-pool"
5+
: "${substr("${var.config.prefix}-pool", 0, 29)}-${substr(md5("${var.config.prefix}-pool"), 0, 8)}"
6+
)
7+
}
8+
19
resource "aws_lambda_function" "pool" {
210

311
s3_bucket = var.config.lambda.s3_bucket != null ? var.config.lambda.s3_bucket : null
@@ -157,7 +165,7 @@ resource "aws_iam_role_policy" "pool_xray" {
157165
}
158166

159167
resource "aws_scheduler_schedule_group" "pool" {
160-
name_prefix = "${var.config.prefix}-pool"
168+
name_prefix = local.pool_name_prefix
161169

162170
tags = var.config.tags
163171
}
@@ -188,7 +196,7 @@ data "aws_iam_policy_document" "scheduler" {
188196
}
189197

190198
resource "aws_iam_role" "scheduler" {
191-
name_prefix = "${var.config.prefix}-pool"
199+
name_prefix = local.pool_name_prefix
192200

193201
path = var.config.role_path
194202
permissions_boundary = var.config.role_permissions_boundary

0 commit comments

Comments
 (0)