Skip to content

Commit 55cf836

Browse files
committed
Apply SSM changes for multi-runner
1 parent 695b263 commit 55cf836

File tree

11 files changed

+66
-9
lines changed

11 files changed

+66
-9
lines changed

examples/default/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
environment = "default"
2+
environment = var.environment != null ? var.environment : "default"
33
aws_region = "eu-west-1"
44
}
55

@@ -85,4 +85,6 @@ module "runners" {
8585
scale_down_schedule_expression = "cron(* * * * ? *)"
8686
# enable this flag to publish webhook events to workflow job queue
8787
# enable_workflow_job_events_queue = true
88+
89+
enable_user_data_debug_logging_runner = true
8890
}

examples/default/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@
22
variable "github_app_key_base64" {}
33

44
variable "github_app_id" {}
5+
6+
variable "environment" {
7+
type = string
8+
default = null
9+
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ module "ssm" {
117117
source = "./modules/ssm"
118118

119119
kms_key_arn = var.kms_key_arn
120-
path_prefix = local.ssm_root_path
120+
path_prefix = "${local.ssm_root_path}/${var.ssm_paths.app}"
121121
github_app = var.github_app
122122
tags = local.tags
123123
}

modules/multi-runner/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ No requirements.
151151
| <a name="input_runners_lambda_zip"></a> [runners\_lambda\_zip](#input\_runners\_lambda\_zip) | File location of the lambda zip file for scaling runners. | `string` | `null` | no |
152152
| <a name="input_runners_scale_down_lambda_timeout"></a> [runners\_scale\_down\_lambda\_timeout](#input\_runners\_scale\_down\_lambda\_timeout) | Time out for the scale down lambda in seconds. | `number` | `60` | no |
153153
| <a name="input_runners_scale_up_lambda_timeout"></a> [runners\_scale\_up\_lambda\_timeout](#input\_runners\_scale\_up\_lambda\_timeout) | Time out for the scale up lambda in seconds. | `number` | `30` | no |
154+
| <a name="input_ssm_paths"></a> [ssm\_paths](#input\_ssm\_paths) | The root path used in SSM to store configuration and secreets. | <pre>object({<br> root = string<br> app = string<br> runners = string<br> })</pre> | <pre>{<br> "app": "app",<br> "root": "github-action-runners",<br> "runners": "runners"<br>}</pre> | no |
154155
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | n/a | yes |
155156
| <a name="input_syncer_lambda_s3_key"></a> [syncer\_lambda\_s3\_key](#input\_syncer\_lambda\_s3\_key) | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
156157
| <a name="input_syncer_lambda_s3_object_version"></a> [syncer\_lambda\_s3\_object\_version](#input\_syncer\_lambda\_s3\_object\_version) | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |

modules/multi-runner/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ locals {
1414

1515
tmp_distinct_list_unique_os_and_arch = distinct([for i, config in local.runner_config : { "os_type" : config.runner_config.runner_os, "architecture" : config.runner_config.runner_architecture } if config.runner_config.enable_runner_binaries_syncer])
1616
unique_os_and_arch = { for i, v in local.tmp_distinct_list_unique_os_and_arch : "${v.os_type}_${v.architecture}" => v }
17+
18+
ssm_root_path = "/${var.ssm_paths.root}"
1719
}
1820

1921
resource "random_string" "random" {

modules/multi-runner/runners.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ module "runners" {
1212

1313
s3_runner_binaries = each.value.runner_config.enable_runner_binaries_syncer ? local.runner_binaries_by_os_and_arch_map["${each.value.runner_config.runner_os}_${each.value.runner_config.runner_architecture}"] : {}
1414

15+
ssm_paths = {
16+
root = "${local.ssm_root_path}/${var.prefix}-${each.key}"
17+
tokens = "${var.ssm_paths.runners}/tokens"
18+
config = "${var.ssm_paths.runners}/config"
19+
}
20+
1521
runner_os = each.value.runner_config.runner_os
1622
instance_types = each.value.runner_config.instance_types
1723
instance_target_capacity_type = each.value.runner_config.instance_target_capacity_type

modules/multi-runner/ssm.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module "ssm" {
22
source = "../ssm"
33

44
kms_key_arn = var.kms_key_arn
5-
prefix = var.prefix
5+
path_prefix = "${local.ssm_root_path}/${var.ssm_paths.app}"
66
github_app = var.github_app
77
tags = local.tags
88
}

modules/multi-runner/variables.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,17 @@ variable "pool_lambda_reserved_concurrent_executions" {
489489
type = number
490490
default = 1
491491
}
492+
493+
variable "ssm_paths" {
494+
description = "The root path used in SSM to store configuration and secreets."
495+
type = object({
496+
root = string
497+
app = string
498+
runners = string
499+
})
500+
default = {
501+
root = "github-action-runners"
502+
runners = "runners"
503+
app = "app"
504+
}
505+
}

modules/multi-runner/webhook.tf

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ module "webhook" {
44
tags = local.tags
55
kms_key_arn = var.kms_key_arn
66

7-
runner_config = local.runner_config
8-
github_app_webhook_secret_arn = module.ssm.parameters.github_app_webhook_secret.arn
7+
runner_config = local.runner_config
8+
9+
github_app_parameters = {
10+
webhook_secret = module.ssm.parameters.github_app_webhook_secret
11+
}
912

1013
lambda_s3_bucket = var.lambda_s3_bucket
1114
webhook_lambda_s3_key = var.webhook_lambda_s3_key

modules/runners/lambdas/runners/yarn.lock

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3704,6 +3704,30 @@ jest-snapshot@^29.2.1:
37043704
pretty-format "^29.2.1"
37053705
semver "^7.3.5"
37063706

3707+
jest-util@^29.0.0:
3708+
version "29.1.2"
3709+
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.1.2.tgz#ac5798e93cb6a6703084e194cfa0898d66126df1"
3710+
integrity sha512-vPCk9F353i0Ymx3WQq3+a4lZ07NXu9Ca8wya6o4Fe4/aO1e1awMMprZ3woPFpKwghEOW+UXgd15vVotuNN9ONQ==
3711+
dependencies:
3712+
"@jest/types" "^29.1.2"
3713+
"@types/node" "*"
3714+
chalk "^4.0.0"
3715+
ci-info "^3.2.0"
3716+
graceful-fs "^4.2.9"
3717+
picomatch "^2.2.3"
3718+
3719+
jest-util@^29.2.0:
3720+
version "29.2.0"
3721+
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.2.0.tgz#797935697e83a5722aeba401ed6cd01264295566"
3722+
integrity sha512-8M1dx12ujkBbnhwytrezWY0Ut79hbflwodE+qZKjxSRz5qt4xDp6dQQJaOCFvCmE0QJqp9KyEK33lpPNjnhevw==
3723+
dependencies:
3724+
"@jest/types" "^29.2.0"
3725+
"@types/node" "*"
3726+
chalk "^4.0.0"
3727+
ci-info "^3.2.0"
3728+
graceful-fs "^4.2.9"
3729+
picomatch "^2.2.3"
3730+
37073731
jest-util@^29.2.1:
37083732
version "29.2.1"
37093733
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.2.1.tgz#f26872ba0dc8cbefaba32c34f98935f6cf5fc747"

modules/runners/templates/start-runner.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ echo "Retrieved ghr:ssm_config_path tag - ($ssm_config_path)"
2323
parameters=$(aws ssm get-parameters-by-path --path "$ssm_config_path" --region "$region" --query "Parameters[*].{Name:Name,Value:Value}")
2424
echo "Retrieved parameters from AWS SSM ($parameters)"
2525

26-
run_as=$(echo "$parameters" | jq -r '.[] | select(.Name == "($ssm_config_path)/run-as") | .Value')
26+
run_as=$(echo "$parameters" | jq -r '.[] | select(.Name == "'$ssm_config_path'/run-as") | .Value')
2727
echo "Retrieved /$ssm_config_path/run-as parameter - ($run_as)"
2828

29-
enable_cloudwatch_agent=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "\($ssm_config_path)/enable-cloudwatch") | .Value')
29+
enable_cloudwatch_agent=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/enable-cloudwatch") | .Value')
3030
echo "Retrieved /$ssm_config_path/enable-cloudwatch parameter - ($enable_cloudwatch_agent)"
3131

32-
agent_mode=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "\($ssm_config_path)/agent-mode") | .Value')
32+
agent_mode=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/agent-mode") | .Value')
3333
echo "Retrieved /$ssm_config_path/agent-mode parameter - ($agent_mode)"
3434

35-
token_path=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "\($ssm_config_path)/token_path") | .Value')
35+
token_path=$(echo "$parameters" | jq --arg ssm_config_path "$ssm_config_path" -r '.[] | select(.Name == "'$ssm_config_path'/token_path") | .Value')
3636
echo "Retrieved /$ssm_config_path/token_path parameter - ($token_path)"
3737

3838
if [[ "$enable_cloudwatch_agent" == "true" ]]; then

0 commit comments

Comments
 (0)