Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/compute-providers/aws/ec2/runner-instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ locals {
"ghr:environment" = var.prefix
"ghr:ssm_config_path" = "${var.storage_provider.aws.ssm.paths.root}/${var.storage_provider.aws.ssm.paths.config}"
"ghr:runner_name_prefix" = var.runner.name_prefix
# JIT and bootstrap registration both use this prefix in the v2 provider.
# Keep the watcher identity tag module-controlled, like the bootstrap tags.
"ghr:registered_runner_name_prefix" = var.runner.name_prefix
},
)

Expand Down
14 changes: 8 additions & 6 deletions modules/compute-providers/aws/ec2/tests/provider.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,13 @@ run "separates_provider_runner_and_ssm_tags" {
}
managed_security_group_enabled = true
tags = {
Name = "runner-name"
Scope = "runner"
RunnerOnly = "runner"
"ghr:environment" = "runner-override"
"ghr:ssm_config_path" = "/runner/override"
"ghr:runner_name_prefix" = "runner-override"
Name = "runner-name"
Scope = "runner"
RunnerOnly = "runner"
"ghr:environment" = "runner-override"
"ghr:ssm_config_path" = "/runner/override"
"ghr:runner_name_prefix" = "runner-override"
"ghr:registered_runner_name_prefix" = "untrusted-override"
}
}
tags = {
Expand Down Expand Up @@ -407,6 +408,7 @@ run "separates_provider_runner_and_ssm_tags" {
&& tag_specification.tags["ghr:environment"] == "provider-test"
&& tag_specification.tags["ghr:ssm_config_path"] == "/github-runner/provider-test/config"
&& tag_specification.tags["ghr:runner_name_prefix"] == "required-prefix"
&& try(tag_specification.tags["ghr:registered_runner_name_prefix"], null) == "required-prefix"
)
])
error_message = "Runner resource tags must apply runner overrides while protecting mandatory bootstrap tags."
Expand Down
2 changes: 1 addition & 1 deletion modules/runner-config/README.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions modules/runner-config/orchestration-provider.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
locals {
ssm_token_environment_variables = var.storage_provider.aws.ssm.ttl_seconds.tokens != null ? {
SSM_TOKEN_TTL_SECONDS = tostring(var.storage_provider.aws.ssm.ttl_seconds.tokens)
} : {}

orchestration_providers = {
for provider_type, provider_config in var.orchestration_provider : provider_type => provider_config
if provider_config != null
Expand Down Expand Up @@ -57,6 +61,8 @@ module "orchestration_webhook" {
parameter_store_max_writes_per_second = var.storage_provider.aws.ssm.parameters.max_writes_per_second
}
}
scale_up = { environment_variables = local.ssm_token_environment_variables }
pool = { environment_variables = local.ssm_token_environment_variables }
}
observability = var.observability

Expand Down
103 changes: 103 additions & 0 deletions modules/runner-config/tests/pool.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,106 @@ run "job_retry_uses_common_runner_configuration_identity" {
error_message = "Job retry must apply its configured Lambda reserved concurrency."
}
}

run "token_ttl_is_unset_by_default" {
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 = "An unset TTL must not add an expiration setting to scale-up or pool."
}
}

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 = 3600 }
}
}
}
}

assert {
condition = (
try(module.orchestration_webhook[0].scale_up.lambda.environment[0].variables["SSM_TOKEN_TTL_SECONDS"], null) == "3600"
&& try(module.orchestration_webhook[0].pool.lambda.environment[0].variables["SSM_TOKEN_TTL_SECONDS"], null) == "3600"
)
error_message = "The configured token TTL must reach both runtime parameter writers."
}
}

run "rejects_zero_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]
}

run "rejects_negative_token_ttl" {
command = plan

variables {
storage_provider = {
aws = {
ssm = {
paths = { root = "/github-runner", tokens = "tokens", config = "config" }
ttl_seconds = { tokens = -1 }
}
}
}
}

expect_failures = [var.storage_provider]
}

run "rejects_subsecond_token_ttl" {
command = plan

variables {
storage_provider = {
aws = {
ssm = {
paths = { root = "/github-runner", tokens = "tokens", config = "config" }
ttl_seconds = { tokens = 0.5 }
}
}
}
}

expect_failures = [var.storage_provider]
}

run "rejects_fractional_token_ttl" {
command = plan

variables {
storage_provider = {
aws = {
ssm = {
paths = { root = "/github-runner", tokens = "tokens", config = "config" }
ttl_seconds = { tokens = 1.5 }
}
}
}
}

expect_failures = [var.storage_provider]
}
11 changes: 11 additions & 0 deletions modules/runner-config/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ variable "storage_provider" {
- `storage_provider.aws.ssm.paths.root`: Root Parameter Store path for this runner configuration.
- `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.ttl_seconds.tokens`: Optional positive whole-second TTL for runtime registration-token and JIT parameters. Null leaves expiration disabled.
- `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.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`.
Expand Down Expand Up @@ -173,6 +174,9 @@ variable "storage_provider" {
tokens = string
config = string
})
ttl_seconds = optional(object({
tokens = optional(number, null)
}), {})
kms_key_id = optional(string, null)
tags = optional(map(string), {})
parameters = optional(object({
Expand Down Expand Up @@ -205,6 +209,13 @@ variable "storage_provider" {
})
})

validation {
condition = var.storage_provider.aws.ssm.ttl_seconds.tokens == null ? true : (
var.storage_provider.aws.ssm.ttl_seconds.tokens > 0 &&
floor(var.storage_provider.aws.ssm.ttl_seconds.tokens) == var.storage_provider.aws.ssm.ttl_seconds.tokens
)
error_message = "`storage_provider.aws.ssm.ttl_seconds.tokens` must be a positive whole number of seconds."
}
}

variable "observability" {
Expand Down
Loading