Skip to content

Commit 4dd211d

Browse files
refactor(runner-stack): key provider output dynamically
1 parent c486d6a commit 4dd211d

9 files changed

Lines changed: 18 additions & 14 deletions

File tree

modules/multi-runner/tests/provider-routing.tftest.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ run "experimental_v2_routes_through_provider_stack" {
203203
assert {
204204
condition = (
205205
local.compute_provider_types["linux"] == "ec2"
206-
&& local.runner_matcher_config["linux"].runnerProvider == "ec2"
206+
&& local.runner_matcher_config["linux"].computeProvider == "ec2"
207207
)
208208
error_message = "Compute-provider selection must supply the webhook routing contract."
209209
}

modules/multi-runner/webhook.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
locals {
22
runner_matcher_config = {
33
for k, v in local.multi_runner_config : k => {
4-
id = aws_sqs_queue.queued_builds[k].id
5-
arn = aws_sqs_queue.queued_builds[k].arn
6-
runnerProvider = local.compute_provider_types[k]
7-
matcherConfig = v.matcherConfig
4+
id = aws_sqs_queue.queued_builds[k].id
5+
arn = aws_sqs_queue.queued_builds[k].arn
6+
computeProvider = local.compute_provider_types[k]
7+
matcherConfig = v.matcherConfig
88
}
99
}
1010
}

modules/runner-stack/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ yarn run dist
122122
| Name | Description |
123123
|------|-------------|
124124
| <a name="output_pool"></a> [pool](#output\_pool) | Scheduled pool resources. Null when no pool configuration is supplied. |
125-
| <a name="output_provider"></a> [provider](#output\_provider) | Provider-specific resources grouped by compute provider. |
125+
| <a name="output_provider"></a> [provider](#output\_provider) | Provider-specific resources grouped under the selected provider key. |
126126
| <a name="output_runner"></a> [runner](#output\_runner) | Common runner resources. The role is null when an external runner role is used. |
127127
| <a name="output_scale_down"></a> [scale\_down](#output\_scale\_down) | Scale-down control-plane resources. |
128128
| <a name="output_scale_up"></a> [scale\_up](#output\_scale\_up) | Scale-up control-plane resources. |

modules/runner-stack/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ output "pool" {
2121
}
2222

2323
output "provider" {
24-
description = "Provider-specific resources grouped by compute provider."
24+
description = "Provider-specific resources grouped under the selected provider key."
2525
value = {
26-
ec2 = local.provider.resources
26+
(local.provider_type) = local.provider.resources
2727
}
2828
}

modules/runner-stack/scale-runners/scale-down.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ resource "aws_lambda_function" "scale_down" {
3131
POWERTOOLS_TRACE_ENABLED = var.config.observability.tracing.mode != null
3232
POWERTOOLS_TRACER_CAPTURE_HTTPS_REQUESTS = var.config.observability.tracing.capture_http_requests
3333
POWERTOOLS_TRACER_CAPTURE_ERROR = var.config.observability.tracing.capture_error
34-
RUNNER_PROVIDER_TYPE = var.runner_provider.type
34+
COMPUTE_PROVIDER_TYPE = var.runner_provider.type
3535
})
3636
}
3737

modules/runner-stack/scale-runners/scale-up.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resource "aws_lambda_function" "scale_up" {
3838
RUNNER_LABELS = lower(join(",", var.config.runner.labels))
3939
RUNNER_GROUP_NAME = var.config.runner.group_name
4040
RUNNER_NAME_PREFIX = var.config.runner.name_prefix
41-
RUNNER_PROVIDER_TYPE = var.runner_provider.type
41+
COMPUTE_PROVIDER_TYPE = var.runner_provider.type
4242
RUNNERS_MAXIMUM_COUNT = var.config.runner.maximum_count
4343
POWERTOOLS_SERVICE_NAME = "${var.config.prefix}-scale-up"
4444
SSM_TOKEN_PATH = var.config.ssm.token_path

modules/runner-stack/scale-runners/tests/scale-runners.tftest.hcl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ run "assembles_provider_neutral_scaling_control_plane" {
202202

203203
assert {
204204
condition = (
205-
aws_lambda_function.scale_up.environment[0].variables["RUNNER_PROVIDER_TYPE"] == "microvm"
205+
aws_lambda_function.scale_up.environment[0].variables["COMPUTE_PROVIDER_TYPE"] == "microvm"
206+
&& aws_lambda_function.scale_down.environment[0].variables["COMPUTE_PROVIDER_TYPE"] == "microvm"
206207
&& aws_lambda_function.scale_up.environment[0].variables["MICROVM_CLUSTER"] == "runner-cluster"
207208
&& aws_lambda_function.scale_down.environment[0].variables["MICROVM_CLUSTER"] == "runner-cluster"
208209
&& !contains(keys(aws_lambda_function.scale_up.environment[0].variables), "INSTANCE_TYPES")

modules/runner-stack/tests/pool.tftest.hcl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@ run "plan_with_pool_enabled" {
152152
}
153153

154154
assert {
155-
condition = module.scale_runners.scale_up.lambda.environment[0].variables["RUNNER_PROVIDER_TYPE"] == "ec2"
156-
error_message = "Scale-up must receive the provider type from the selected provider."
155+
condition = (
156+
module.scale_runners.scale_up.lambda.environment[0].variables["COMPUTE_PROVIDER_TYPE"] == "ec2"
157+
&& module.scale_runners.scale_down.lambda.environment[0].variables["COMPUTE_PROVIDER_TYPE"] == "ec2"
158+
)
159+
error_message = "Scaling Lambdas must receive the provider type from the selected provider."
157160
}
158161

159162
assert {

modules/webhook/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ variable "tags" {
2323
}
2424

2525
variable "runner_matcher_config" {
26-
description = "SQS queue to publish accepted build events based on the runner type. `computeProvider` defaults to `ec2`; EC2 is currently the only Terraform-managed provider. When exact match is disabled the webhook accepts the event if one of the workflow job labels is part of the matcher. The priority defines the order the matchers are applied. Optional `matcherConfig.enableDynamicLabels` and `matcherConfig.awsDynamicLabelsPolicy` are evaluated by the dispatcher to gate provider dynamic labels per runner. The policy supports `blocked_keys = [<key>]` and `restricted_keys = { <key> = { allowed = [globs], denied = [globs], max = number|string } }`; keys use the provider dynamic label suffix form, for example `instance-type` for `ghr-ec2-instance-type`."
26+
description = "SQS queue to publish accepted build events based on the runner type. `computeProvider` defaults to `ec2`; EC2 is the only provider currently implemented. When exact match is disabled the webhook accepts the event if one of the workflow job labels is part of the matcher. The priority defines the order the matchers are applied. Optional `matcherConfig.enableDynamicLabels` and `matcherConfig.awsDynamicLabelsPolicy` are evaluated by the dispatcher to gate provider dynamic labels per runner. The policy supports `blocked_keys = [<key>]` and `restricted_keys = { <key> = { allowed = [globs], denied = [globs], max = number|string } }`; keys use the provider dynamic label suffix form, for example `instance-type` for `ghr-ec2-instance-type`."
2727
type = map(object({
2828
arn = string
2929
id = string

0 commit comments

Comments
 (0)