From d268e6110594d13da48b54c7bf8e06930ddd6ab8 Mon Sep 17 00:00:00 2001 From: Alex Jurkiewicz Date: Thu, 28 May 2026 21:07:39 +0800 Subject: [PATCH] fix(runner): handle long prefixes in pool scheduler and IAM resource names 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. When the module prefix is long (e.g. via multi-runner map keys), this limit is exceeded and Terraform fails. Add a local that passes the prefix through unchanged when it fits, and falls back to a truncated prefix with an md5 hash suffix when it exceeds 38 characters. This matches the existing pattern used for the pool lambda IAM role on line 80. Co-Authored-By: Claude Opus 4.6 --- modules/runners/pool/main.tf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/runners/pool/main.tf b/modules/runners/pool/main.tf index ec8b50bbd5..15e19234b7 100644 --- a/modules/runners/pool/main.tf +++ b/modules/runners/pool/main.tf @@ -1,3 +1,11 @@ +locals { + pool_name_prefix = ( + length("${var.config.prefix}-pool") <= 38 + ? "${var.config.prefix}-pool" + : "${substr("${var.config.prefix}-pool", 0, 29)}-${substr(md5("${var.config.prefix}-pool"), 0, 8)}" + ) +} + resource "aws_lambda_function" "pool" { 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" { } resource "aws_scheduler_schedule_group" "pool" { - name_prefix = "${var.config.prefix}-pool" + name_prefix = local.pool_name_prefix tags = var.config.tags } @@ -188,7 +196,7 @@ data "aws_iam_policy_document" "scheduler" { } resource "aws_iam_role" "scheduler" { - name_prefix = "${var.config.prefix}-pool" + name_prefix = local.pool_name_prefix path = var.config.role_path permissions_boundary = var.config.role_permissions_boundary