From bec269eaa1bcc9346a4ec752a2f1eec71462f151 Mon Sep 17 00:00:00 2001 From: Vishal Wadhera Date: Sat, 21 Nov 2026 12:28:05 +0530 Subject: [PATCH 1/3] fix(multi-runner): pass v2 storage_provider token TTL to scale-up and pool A multi-runner v2 lane accepted storage_provider.aws.ssm.ttl_seconds.tokens, but runner-config's storage_provider type had no ttl_seconds attribute, so the value was dropped and SSM_TOKEN_TTL_SECONDS never reached the scale-up or pool Lambdas. Token parameters were created without an expiration policy, and migrating a v1 lane to v2 removed the variable. runner-config now accepts and validates ttl_seconds.tokens and hands it to the webhook orchestration provider as storage_provider.aws.ssm.token_ttl_seconds. The scale-up and pool Lambdas set SSM_TOKEN_TTL_SECONDS when it is not null, matching modules/runners. Fixes #5602 Co-Authored-By: Claude Opus 5.5 --- .../tests/config-translation.tftest.hcl | 5 ++ .../webhook/pool/pool.tf | 6 +- .../webhook/pool/variables.tf | 1 + .../webhook/scale-runners/scale-up.tf | 4 +- .../webhook/scale-runners/variables.tf | 2 + .../webhook/variables.tf | 2 + .../runner-config/orchestration-provider.tf | 1 + modules/runner-config/tests/pool.tftest.hcl | 60 +++++++++++++++++++ modules/runner-config/variables.tf | 10 +++- 9 files changed, 87 insertions(+), 4 deletions(-) diff --git a/modules/multi-runner/tests/config-translation.tftest.hcl b/modules/multi-runner/tests/config-translation.tftest.hcl index c693e64bff..8347233b9e 100644 --- a/modules/multi-runner/tests/config-translation.tftest.hcl +++ b/modules/multi-runner/tests/config-translation.tftest.hcl @@ -542,6 +542,11 @@ run "non_empty_v2_map_is_authoritative" { error_message = "A non-empty v2 runner map must be authoritative and must not merge stable lanes or flat defaults." } + assert { + condition = module.runner_configs["experimental"].orchestration_provider.webhook.scale_up.lambda.environment[0].variables["SSM_TOKEN_TTL_SECONDS"] == "7200" + error_message = "A v2 lane token TTL must reach the scale-up Lambda environment." + } + assert { condition = jsonencode(local.normalized_config) == jsonencode(local.v2_config) error_message = "A non-empty v2 runner map must select the v2 object without leaking stable flat inputs." diff --git a/modules/orchestration-providers/webhook/pool/pool.tf b/modules/orchestration-providers/webhook/pool/pool.tf index 43e3653e8f..6d2e0ca7e9 100644 --- a/modules/orchestration-providers/webhook/pool/pool.tf +++ b/modules/orchestration-providers/webhook/pool/pool.tf @@ -29,7 +29,7 @@ locals { INCLUDE_BUSY_RUNNERS = var.config.include_busy_runners } - ssm_environment_variables = { + ssm_environment_variables = merge({ PARAMETER_GITHUB_APP_ID_NAME = var.config.github_app_parameters.id.name PARAMETER_GITHUB_APP_KEY_BASE64_NAME = var.config.github_app_parameters.key_base64.name PARAMETER_GITHUB_APPS_MANIFEST_NAME = var.config.github_app_parameters.additional_apps_manifest != null ? var.config.github_app_parameters.additional_apps_manifest.name : "" @@ -38,7 +38,9 @@ locals { SSM_PARAMETER_STORE_TAGS = var.storage_provider.aws.ssm.parameter_store_tags SSM_PARAMETER_STORE_MAX_CONCURRENT_INVOCATIONS = var.storage_provider.aws.ssm.parameter_store_max_concurrent_invocations SSM_PARAMETER_STORE_MAX_WRITES_PER_SECOND = var.storage_provider.aws.ssm.parameter_store_max_writes_per_second - } + }, var.storage_provider.aws.ssm.token_ttl_seconds != null ? { + SSM_TOKEN_TTL_SECONDS = tostring(var.storage_provider.aws.ssm.token_ttl_seconds) + } : {}) } resource "aws_lambda_function" "pool" { diff --git a/modules/orchestration-providers/webhook/pool/variables.tf b/modules/orchestration-providers/webhook/pool/variables.tf index eb10c1e586..2b776b0be1 100644 --- a/modules/orchestration-providers/webhook/pool/variables.tf +++ b/modules/orchestration-providers/webhook/pool/variables.tf @@ -145,6 +145,7 @@ variable "storage_provider" { parameter_store_max_concurrent_invocations = optional(number, 1) parameter_store_max_writes_per_second = optional(number, 40) + token_ttl_seconds = optional(number, null) }) }) environment_variables = optional(map(string), {}) diff --git a/modules/orchestration-providers/webhook/scale-runners/scale-up.tf b/modules/orchestration-providers/webhook/scale-runners/scale-up.tf index cc26020663..379415cf9b 100644 --- a/modules/orchestration-providers/webhook/scale-runners/scale-up.tf +++ b/modules/orchestration-providers/webhook/scale-runners/scale-up.tf @@ -49,7 +49,9 @@ resource "aws_lambda_function" "scale_up" { SSM_PARAMETER_STORE_TAGS = var.storage_provider.aws.ssm.parameter_store_tags SSM_PARAMETER_STORE_MAX_CONCURRENT_INVOCATIONS = var.storage_provider.aws.ssm.parameter_store_max_concurrent_invocations SSM_PARAMETER_STORE_MAX_WRITES_PER_SECOND = var.storage_provider.aws.ssm.parameter_store_max_writes_per_second - }, var.storage_provider.scale_up.environment_variables) + }, var.storage_provider.aws.ssm.token_ttl_seconds != null ? { + SSM_TOKEN_TTL_SECONDS = tostring(var.storage_provider.aws.ssm.token_ttl_seconds) + } : {}, var.storage_provider.scale_up.environment_variables) } dynamic "vpc_config" { diff --git a/modules/orchestration-providers/webhook/scale-runners/variables.tf b/modules/orchestration-providers/webhook/scale-runners/variables.tf index 0e35c41160..95ab401bbe 100644 --- a/modules/orchestration-providers/webhook/scale-runners/variables.tf +++ b/modules/orchestration-providers/webhook/scale-runners/variables.tf @@ -49,6 +49,7 @@ variable "config" { - `storage_provider.aws.ssm.parameter_store_tags`: JSON-encoded tags applied to parameters created at runtime. - `storage_provider.aws.ssm.parameter_store_max_concurrent_invocations`: Expected number of concurrent scale-up and pool Lambda invocations writing to Parameter Store, used to pace writes. - `storage_provider.aws.ssm.parameter_store_max_writes_per_second`: Parameter Store write-rate limit, in writes per second, that runtime writes are paced against. + - `storage_provider.aws.ssm.token_ttl_seconds`: Optional TTL in seconds for registration-token and JIT-config parameters. Null leaves SSM expiration policies disabled. - `observability.logs`: Shared logging level, retention, encryption, and log-class configuration. - `observability.tracing`: Lambda X-Ray and tracing-helper configuration. - `observability.metrics`: Metrics enablement, namespace, and GitHub rate-limit metric configuration. @@ -247,6 +248,7 @@ variable "storage_provider" { parameter_store_max_concurrent_invocations = optional(number, 1) parameter_store_max_writes_per_second = optional(number, 40) + token_ttl_seconds = optional(number, null) }) }) scale_up = optional(object({ diff --git a/modules/orchestration-providers/webhook/variables.tf b/modules/orchestration-providers/webhook/variables.tf index 57b583730e..c557f5f912 100644 --- a/modules/orchestration-providers/webhook/variables.tf +++ b/modules/orchestration-providers/webhook/variables.tf @@ -221,6 +221,7 @@ variable "storage_provider" { - `storage_provider.aws.ssm.parameter_store_tags`: JSON-encoded tags applied to runtime parameters. - `storage_provider.aws.ssm.parameter_store_max_concurrent_invocations`: Expected number of concurrent scale-up and pool Lambda invocations writing to Parameter Store, used to pace writes. - `storage_provider.aws.ssm.parameter_store_max_writes_per_second`: Parameter Store write-rate limit, in writes per second, that runtime writes are paced against. + - `storage_provider.aws.ssm.token_ttl_seconds`: Optional TTL in seconds for registration-token and JIT-config parameters. Null leaves SSM expiration policies disabled. - `scale_up`, `scale_down`, `pool`, and `job_retry`: Provider-owned environment variables and IAM policy fragments. EOT type = object({ @@ -235,6 +236,7 @@ variable "storage_provider" { parameter_store_max_concurrent_invocations = optional(number, 1) parameter_store_max_writes_per_second = optional(number, 40) + token_ttl_seconds = optional(number, null) }) }) scale_up = optional(object({ diff --git a/modules/runner-config/orchestration-provider.tf b/modules/runner-config/orchestration-provider.tf index b049c70196..7eea1f22ad 100644 --- a/modules/runner-config/orchestration-provider.tf +++ b/modules/runner-config/orchestration-provider.tf @@ -55,6 +55,7 @@ module "orchestration_webhook" { parameter_store_tags = local.parameter_store_tags parameter_store_max_concurrent_invocations = var.storage_provider.aws.ssm.parameters.max_concurrent_invocations parameter_store_max_writes_per_second = var.storage_provider.aws.ssm.parameters.max_writes_per_second + token_ttl_seconds = var.storage_provider.aws.ssm.ttl_seconds.tokens } } } diff --git a/modules/runner-config/tests/pool.tftest.hcl b/modules/runner-config/tests/pool.tftest.hcl index 8537f3f553..56710a8aad 100644 --- a/modules/runner-config/tests/pool.tftest.hcl +++ b/modules/runner-config/tests/pool.tftest.hcl @@ -692,3 +692,63 @@ run "job_retry_uses_common_runner_configuration_identity" { error_message = "Job retry must apply its configured Lambda reserved concurrency." } } + +run "token_ttl_defaults_to_disabled" { + command = plan + + assert { + condition = ( + !contains(keys(module.orchestration_webhook[0].scale_up.lambda.environment[0].variables), "SSM_TOKEN_TTL_SECONDS") + && !contains(keys(module.orchestration_webhook[0].pool.lambda.environment[0].variables), "SSM_TOKEN_TTL_SECONDS") + ) + error_message = "Omitted token TTL must leave expiration disabled." + } +} + +run "token_ttl_reaches_scale_up_and_pool" { + command = plan + + variables { + storage_provider = { + aws = { + ssm = { + paths = { + root = "/github-runner" + tokens = "tokens" + config = "config" + } + ttl_seconds = { tokens = 300 } + } + } + } + } + + assert { + condition = ( + module.orchestration_webhook[0].scale_up.lambda.environment[0].variables["SSM_TOKEN_TTL_SECONDS"] == "300" + && module.orchestration_webhook[0].pool.lambda.environment[0].variables["SSM_TOKEN_TTL_SECONDS"] == "300" + ) + error_message = "The storage-provider token TTL must reach both scale-up and pool Lambdas." + } +} + +run "rejects_non_positive_token_ttl" { + command = plan + + variables { + storage_provider = { + aws = { + ssm = { + paths = { + root = "/github-runner" + tokens = "tokens" + config = "config" + } + ttl_seconds = { tokens = 0 } + } + } + } + } + + expect_failures = [var.storage_provider] +} diff --git a/modules/runner-config/variables.tf b/modules/runner-config/variables.tf index f08d977d37..700a6792ec 100644 --- a/modules/runner-config/variables.tf +++ b/modules/runner-config/variables.tf @@ -147,6 +147,7 @@ variable "storage_provider" { - `storage_provider.aws.ssm.paths.tokens`: Path segment under `paths.root` used for registration tokens and just-in-time configuration. - `storage_provider.aws.ssm.paths.config`: Path segment under `paths.root` used for persistent runner configuration. - `storage_provider.aws.ssm.kms_key_id`: Optional customer-managed KMS key ARN used by control-plane IAM policies to decrypt shared GitHub App parameters. The ARN may be unknown until apply; null omits the provider-owned KMS statements. It does not select encryption for runtime-created runner parameters. + - `storage_provider.aws.ssm.ttl_seconds.tokens`: Optional TTL in seconds for the Parameter Store parameters holding the runner registration token or just-in-time configuration. When set, the scale-up and pool Lambdas create these parameters with an SSM expiration policy. Requires the Advanced parameter tier, which incurs additional costs. Must be a positive number and should comfortably exceed the runner boot time. Null leaves native expiration disabled. - `storage_provider.aws.ssm.tags`: Shared tags for SSM-related resources. These override module-level `tags` and are inherited by parameter and housekeeper resources. - `storage_provider.aws.ssm.parameters.max_concurrent_invocations`: Expected number of concurrent scale-up and pool Lambda invocations writing to Parameter Store. Each invocation paces its writes to a share of the account-wide write-rate limit. The default is `1`. - `storage_provider.aws.ssm.parameters.max_writes_per_second`: Parameter Store write rate to pace against, in writes per second. AWS documents a `PutParameter` quota of 3 TPS per account and Region (10 TPS with higher throughput enabled). The default of 40 keeps the previous pacing; lower it if `PutParameter` calls are throttled. @@ -174,7 +175,10 @@ variable "storage_provider" { config = string }) kms_key_id = optional(string, null) - tags = optional(map(string), {}) + ttl_seconds = optional(object({ + tokens = optional(number, null) + }), {}) + tags = optional(map(string), {}) parameters = optional(object({ tags = optional(map(string), {}) max_concurrent_invocations = optional(number, 1) @@ -205,6 +209,10 @@ variable "storage_provider" { }) }) + validation { + condition = var.storage_provider.aws.ssm.ttl_seconds.tokens == null ? true : var.storage_provider.aws.ssm.ttl_seconds.tokens > 0 + error_message = "`storage_provider.aws.ssm.ttl_seconds.tokens` must be a positive number." + } } variable "observability" { From 7a0bbec33534de66612ac616008b205b564620f7 Mon Sep 17 00:00:00 2001 From: Vishal Wadhera Date: Mon, 23 Nov 2026 15:17:51 +0530 Subject: [PATCH 2/3] fix(multi-runner): apply token TTL to scale-set JIT config parameters Scale-set lanes stored each runner's JIT configuration in SSM without an Expiration policy, so parameters for instances that never booted were left behind indefinitely. Pass storage_provider.aws.ssm.ttl_seconds.tokens to the EC2 scale-set controller as jitConfigTtlSeconds. When set, publishJitConfiguration uses the Advanced tier and attaches an Expiration policy, matching the webhook lanes. Behaviour is unchanged when the TTL is omitted. Fixes #5604 Co-Authored-By: Claude Opus 5.5 --- .../ec2/src/scale-set/configuration.test.ts | 8 ++++ .../aws/ec2/src/scale-set/configuration.ts | 11 ++++++ .../aws/ec2/src/scale-set/scale-up.test.ts | 39 +++++++++++++++++++ .../aws/ec2/src/scale-set/scale-up.ts | 17 +++++++- .../compute-providers/aws/ec2/scale-set.tf | 3 ++ .../compute-providers/aws/ec2/variables.tf | 4 ++ modules/runner-config/variables.tf | 2 +- 7 files changed, 82 insertions(+), 2 deletions(-) diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts index 5fe55d59aa..210c1b8d78 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts @@ -12,6 +12,10 @@ describe('EC2 scale-set provider configuration', () => { expect(parseEc2ScaleSetProviderConfig({ ...config, runnerNamePrefix: 'r'.repeat(45) })).toMatchObject({ runnerNamePrefix: 'r'.repeat(45), }); + expect(parseEc2ScaleSetProviderConfig(config).jitConfigTtlSeconds).toBeUndefined(); + expect(parseEc2ScaleSetProviderConfig({ ...config, jitConfigTtlSeconds: 3600 })).toMatchObject({ + jitConfigTtlSeconds: 3600, + }); }); it.each([ @@ -22,6 +26,10 @@ describe('EC2 scale-set provider configuration', () => { [{ ...config, ssmParameterTags: [{ Key: 'aws:owner', Value: 'untrusted' }] }], [{ ...config, runnerNamePrefix: 'r'.repeat(46) }], [{ ...config, bootTimeoutMinutes: 10 }], + [{ ...config, jitConfigTtlSeconds: 0 }], + [{ ...config, jitConfigTtlSeconds: -1 }], + [{ ...config, jitConfigTtlSeconds: Number.NaN }], + [{ ...config, jitConfigTtlSeconds: '3600' }], ])('rejects invalid or unsupported values instead of forwarding them to AWS', (invalid) => { expect(() => parseEc2ScaleSetProviderConfig(invalid)).toThrow(); }); diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts index 91ae93d555..69398b7483 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts @@ -18,6 +18,7 @@ export interface Ec2ScaleSetProviderConfig { environment: string; runnerNamePrefix: string; jitConfigParameterPath: string; + jitConfigTtlSeconds?: number; subnets: string[]; launchTemplateName: string; ec2instanceCriteria: RunnerInputParameters['ec2instanceCriteria']; @@ -72,6 +73,14 @@ function optionalBoolean(value: unknown, name: string): boolean | undefined { return value; } +function optionalPositiveNumber(value: unknown, name: string): number | undefined { + if (value === undefined) return undefined; + if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) { + throw new Ec2ScaleSetValidationError(`Invalid EC2 scale-set configuration field '${name}'`); + } + return value; +} + function requireStringArray( value: unknown, name: string, @@ -213,6 +222,7 @@ export function parseEc2ScaleSetProviderConfig(value: unknown): Ec2ScaleSetProvi 'environment', 'runnerNamePrefix', 'jitConfigParameterPath', + 'jitConfigTtlSeconds', 'subnets', 'launchTemplateName', 'ec2instanceCriteria', @@ -271,6 +281,7 @@ export function parseEc2ScaleSetProviderConfig(value: unknown): Ec2ScaleSetProvi environment: requireString(value.environment, 'environment', /^[A-Za-z0-9][A-Za-z0-9._-]*$/, 128), runnerNamePrefix: requirePossiblyEmptyString(value.runnerNamePrefix, 'runnerNamePrefix', /^[A-Za-z0-9._-]*$/, 45), jitConfigParameterPath, + jitConfigTtlSeconds: optionalPositiveNumber(value.jitConfigTtlSeconds, 'jitConfigTtlSeconds'), subnets: requireStringArray(value.subnets, 'subnets', /^subnet-[0-9a-f]+$/, 32), launchTemplateName: requireString(value.launchTemplateName, 'launchTemplateName', /^[A-Za-z0-9()./_-]+$/, 128), ec2instanceCriteria: { diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts index d72c8a50e8..5e445a492c 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts @@ -71,6 +71,45 @@ describe('EC2 scale-set scale up', () => { }); }); + it('publishes the JIT configuration on the Standard tier without a policy when no TTL is configured', async () => { + const instanceId = 'i-1234567890abcdef0'; + ec2Mock.on(DescribeInstancesCommand).resolves({}); + ec2Mock.on(CreateFleetCommand).resolves({ Instances: [{ InstanceIds: [instanceId] }] }); + + await createTestProvider().reconcile(createRequest()); + + expect(ssmMock).toHaveReceivedCommandWith(PutParameterCommand, { Tier: 'Standard', Policies: undefined }); + }); + + it('publishes the JIT configuration on the Advanced tier with an expiration policy when a TTL is configured', async () => { + const instanceId = 'i-1234567890abcdef0'; + const now = new Date('2026-01-01T00:00:00.000Z'); + vi.useFakeTimers({ now, toFake: ['Date'] }); + try { + ec2Mock.on(DescribeInstancesCommand).resolves({}); + ec2Mock.on(CreateFleetCommand).resolves({ Instances: [{ InstanceIds: [instanceId] }] }); + + const result = await createTestProvider({ + configuration: { ...config, jitConfigTtlSeconds: 3600 }, + }).reconcile(createRequest()); + + expect(result.actions.launched).toBe(1); + expect(ssmMock).toHaveReceivedCommandWith(PutParameterCommand, { + Name: `${config.jitConfigParameterPath}/${instanceId}`, + Tier: 'Advanced', + Policies: JSON.stringify([ + { + Type: 'Expiration', + Version: '1.0', + Attributes: { Timestamp: '2026-01-01T01:00:00.000Z' }, + }, + ]), + }); + } finally { + vi.useRealTimers(); + } + }); + it('resolves an AMI parameter through the provider-owned SSM client', async () => { const instanceId = 'i-1234567890abcdef0'; const amiIdSsmParameterName = '/github-action-runners/unit-test/ami'; diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts index ef6cfc3a88..ca6b656544 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts @@ -79,6 +79,11 @@ async function publishJitConfiguration( throw new Ec2ScaleSetValidationError('JIT configuration must be between 1 and 8192 bytes'); } + // Parameter policies (e.g. Expiration) are only supported on the Advanced + // tier, so a TTL forces the tier regardless of the value size. Expiration is + // enforced asynchronously by SSM and only cleans up parameters left behind by + // instances that never read their JIT configuration. + const ttlSeconds = input.configuration.jitConfigTtlSeconds; await ssmClient.send( new PutParameterCommand({ Name: jitParameterName(input.configuration, instanceId), @@ -86,7 +91,17 @@ async function publishJitConfiguration( Type: 'SecureString', KeyId: input.configuration.ssmKmsKeyId, Overwrite: false, - Tier: valueSize >= SSM_STANDARD_TIER_THRESHOLD ? 'Advanced' : 'Standard', + Tier: ttlSeconds !== undefined || valueSize >= SSM_STANDARD_TIER_THRESHOLD ? 'Advanced' : 'Standard', + Policies: + ttlSeconds === undefined + ? undefined + : JSON.stringify([ + { + Type: 'Expiration', + Version: '1.0', + Attributes: { Timestamp: new Date(Date.now() + ttlSeconds * 1000).toISOString() }, + }, + ]), Tags: jitParameterTags(input, instanceId), }), { abortSignal: signal }, diff --git a/modules/compute-providers/aws/ec2/scale-set.tf b/modules/compute-providers/aws/ec2/scale-set.tf index f6246eeb86..f1bfcdb73e 100644 --- a/modules/compute-providers/aws/ec2/scale-set.tf +++ b/modules/compute-providers/aws/ec2/scale-set.tf @@ -37,6 +37,9 @@ locals { local.ami_id_ssm_external ? { amiIdSsmParameterName = local.ami_id_ssm_parameter_name } : {}, + var.storage_provider.aws.ssm.ttl_seconds.tokens == null ? {} : { + jitConfigTtlSeconds = var.storage_provider.aws.ssm.ttl_seconds.tokens + }, ) scale_set_owned_instance_conditions = [ diff --git a/modules/compute-providers/aws/ec2/variables.tf b/modules/compute-providers/aws/ec2/variables.tf index e1fd17428c..4cda0e7e8c 100644 --- a/modules/compute-providers/aws/ec2/variables.tf +++ b/modules/compute-providers/aws/ec2/variables.tf @@ -364,6 +364,7 @@ variable "storage_provider" { - `aws.ssm.paths.root`: Root Parameter Store path for the runner configuration. - `aws.ssm.paths.tokens`: Path segment used for registration tokens and just-in-time configuration. - `aws.ssm.paths.config`: Path segment used for persistent runner and provider configuration. + - `aws.ssm.ttl_seconds.tokens`: Optional TTL in seconds for scale-set just-in-time configuration parameters. When set, the parameters use the Advanced tier with an SSM expiration policy. - `aws.ssm.tags`: Shared SSM tags that override module-level `tags`. - `aws.ssm.parameters.tags`: Parameter-specific tags that override module-level and shared SSM tags. EOT @@ -375,6 +376,9 @@ variable "storage_provider" { tokens = string config = string }) + ttl_seconds = optional(object({ + tokens = optional(number, null) + }), {}) tags = optional(map(string), {}) parameters = optional(object({ tags = optional(map(string), {}) diff --git a/modules/runner-config/variables.tf b/modules/runner-config/variables.tf index 700a6792ec..f32a64651d 100644 --- a/modules/runner-config/variables.tf +++ b/modules/runner-config/variables.tf @@ -147,7 +147,7 @@ variable "storage_provider" { - `storage_provider.aws.ssm.paths.tokens`: Path segment under `paths.root` used for registration tokens and just-in-time configuration. - `storage_provider.aws.ssm.paths.config`: Path segment under `paths.root` used for persistent runner configuration. - `storage_provider.aws.ssm.kms_key_id`: Optional customer-managed KMS key ARN used by control-plane IAM policies to decrypt shared GitHub App parameters. The ARN may be unknown until apply; null omits the provider-owned KMS statements. It does not select encryption for runtime-created runner parameters. - - `storage_provider.aws.ssm.ttl_seconds.tokens`: Optional TTL in seconds for the Parameter Store parameters holding the runner registration token or just-in-time configuration. When set, the scale-up and pool Lambdas create these parameters with an SSM expiration policy. Requires the Advanced parameter tier, which incurs additional costs. Must be a positive number and should comfortably exceed the runner boot time. Null leaves native expiration disabled. + - `storage_provider.aws.ssm.ttl_seconds.tokens`: Optional TTL in seconds for the Parameter Store parameters holding the runner registration token or just-in-time configuration. When set, the webhook scale-up and pool Lambdas and the scale-set controller create these parameters with an SSM expiration policy. Requires the Advanced parameter tier, which incurs additional costs. Must be a positive number and should comfortably exceed the runner boot time. Null leaves native expiration disabled. - `storage_provider.aws.ssm.tags`: Shared tags for SSM-related resources. These override module-level `tags` and are inherited by parameter and housekeeper resources. - `storage_provider.aws.ssm.parameters.max_concurrent_invocations`: Expected number of concurrent scale-up and pool Lambda invocations writing to Parameter Store. Each invocation paces its writes to a share of the account-wide write-rate limit. The default is `1`. - `storage_provider.aws.ssm.parameters.max_writes_per_second`: Parameter Store write rate to pace against, in writes per second. AWS documents a `PutParameter` quota of 3 TPS per account and Region (10 TPS with higher throughput enabled). The default of 40 keeps the previous pacing; lower it if `PutParameter` calls are throttled. From d672ba4b933e77b5ea825dc87c40e7e3651a8bbd Mon Sep 17 00:00:00 2001 From: Vishal Wadhera Date: Mon, 23 Nov 2026 15:20:52 +0530 Subject: [PATCH 3/3] refactor(multi-runner): rename jitConfigTtlSeconds to jitConfigTTLSeconds Co-Authored-By: Claude Opus 5.5 --- .../aws/ec2/src/scale-set/configuration.test.ts | 14 +++++++------- .../aws/ec2/src/scale-set/configuration.ts | 6 +++--- .../aws/ec2/src/scale-set/scale-up.test.ts | 2 +- .../aws/ec2/src/scale-set/scale-up.ts | 2 +- modules/compute-providers/aws/ec2/scale-set.tf | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts index 210c1b8d78..e88370daa5 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.test.ts @@ -12,9 +12,9 @@ describe('EC2 scale-set provider configuration', () => { expect(parseEc2ScaleSetProviderConfig({ ...config, runnerNamePrefix: 'r'.repeat(45) })).toMatchObject({ runnerNamePrefix: 'r'.repeat(45), }); - expect(parseEc2ScaleSetProviderConfig(config).jitConfigTtlSeconds).toBeUndefined(); - expect(parseEc2ScaleSetProviderConfig({ ...config, jitConfigTtlSeconds: 3600 })).toMatchObject({ - jitConfigTtlSeconds: 3600, + expect(parseEc2ScaleSetProviderConfig(config).jitConfigTTLSeconds).toBeUndefined(); + expect(parseEc2ScaleSetProviderConfig({ ...config, jitConfigTTLSeconds: 3600 })).toMatchObject({ + jitConfigTTLSeconds: 3600, }); }); @@ -26,10 +26,10 @@ describe('EC2 scale-set provider configuration', () => { [{ ...config, ssmParameterTags: [{ Key: 'aws:owner', Value: 'untrusted' }] }], [{ ...config, runnerNamePrefix: 'r'.repeat(46) }], [{ ...config, bootTimeoutMinutes: 10 }], - [{ ...config, jitConfigTtlSeconds: 0 }], - [{ ...config, jitConfigTtlSeconds: -1 }], - [{ ...config, jitConfigTtlSeconds: Number.NaN }], - [{ ...config, jitConfigTtlSeconds: '3600' }], + [{ ...config, jitConfigTTLSeconds: 0 }], + [{ ...config, jitConfigTTLSeconds: -1 }], + [{ ...config, jitConfigTTLSeconds: Number.NaN }], + [{ ...config, jitConfigTTLSeconds: '3600' }], ])('rejects invalid or unsupported values instead of forwarding them to AWS', (invalid) => { expect(() => parseEc2ScaleSetProviderConfig(invalid)).toThrow(); }); diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts index 69398b7483..2f14426765 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/configuration.ts @@ -18,7 +18,7 @@ export interface Ec2ScaleSetProviderConfig { environment: string; runnerNamePrefix: string; jitConfigParameterPath: string; - jitConfigTtlSeconds?: number; + jitConfigTTLSeconds?: number; subnets: string[]; launchTemplateName: string; ec2instanceCriteria: RunnerInputParameters['ec2instanceCriteria']; @@ -222,7 +222,7 @@ export function parseEc2ScaleSetProviderConfig(value: unknown): Ec2ScaleSetProvi 'environment', 'runnerNamePrefix', 'jitConfigParameterPath', - 'jitConfigTtlSeconds', + 'jitConfigTTLSeconds', 'subnets', 'launchTemplateName', 'ec2instanceCriteria', @@ -281,7 +281,7 @@ export function parseEc2ScaleSetProviderConfig(value: unknown): Ec2ScaleSetProvi environment: requireString(value.environment, 'environment', /^[A-Za-z0-9][A-Za-z0-9._-]*$/, 128), runnerNamePrefix: requirePossiblyEmptyString(value.runnerNamePrefix, 'runnerNamePrefix', /^[A-Za-z0-9._-]*$/, 45), jitConfigParameterPath, - jitConfigTtlSeconds: optionalPositiveNumber(value.jitConfigTtlSeconds, 'jitConfigTtlSeconds'), + jitConfigTTLSeconds: optionalPositiveNumber(value.jitConfigTTLSeconds, 'jitConfigTTLSeconds'), subnets: requireStringArray(value.subnets, 'subnets', /^subnet-[0-9a-f]+$/, 32), launchTemplateName: requireString(value.launchTemplateName, 'launchTemplateName', /^[A-Za-z0-9()./_-]+$/, 128), ec2instanceCriteria: { diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts index 5e445a492c..0f7c8746c8 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.test.ts @@ -90,7 +90,7 @@ describe('EC2 scale-set scale up', () => { ec2Mock.on(CreateFleetCommand).resolves({ Instances: [{ InstanceIds: [instanceId] }] }); const result = await createTestProvider({ - configuration: { ...config, jitConfigTtlSeconds: 3600 }, + configuration: { ...config, jitConfigTTLSeconds: 3600 }, }).reconcile(createRequest()); expect(result.actions.launched).toBe(1); diff --git a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts index ca6b656544..3f9e94699f 100644 --- a/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts +++ b/lambdas/libs/compute-providers/aws/ec2/src/scale-set/scale-up.ts @@ -83,7 +83,7 @@ async function publishJitConfiguration( // tier, so a TTL forces the tier regardless of the value size. Expiration is // enforced asynchronously by SSM and only cleans up parameters left behind by // instances that never read their JIT configuration. - const ttlSeconds = input.configuration.jitConfigTtlSeconds; + const ttlSeconds = input.configuration.jitConfigTTLSeconds; await ssmClient.send( new PutParameterCommand({ Name: jitParameterName(input.configuration, instanceId), diff --git a/modules/compute-providers/aws/ec2/scale-set.tf b/modules/compute-providers/aws/ec2/scale-set.tf index f1bfcdb73e..beaf0ca9c9 100644 --- a/modules/compute-providers/aws/ec2/scale-set.tf +++ b/modules/compute-providers/aws/ec2/scale-set.tf @@ -38,7 +38,7 @@ locals { amiIdSsmParameterName = local.ami_id_ssm_parameter_name } : {}, var.storage_provider.aws.ssm.ttl_seconds.tokens == null ? {} : { - jitConfigTtlSeconds = var.storage_provider.aws.ssm.ttl_seconds.tokens + jitConfigTTLSeconds = var.storage_provider.aws.ssm.ttl_seconds.tokens }, )