Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit cb60d36

Browse files
authored
Merge pull request #29 from philips-labs/feature/root-runners
Allow the github action runner to be run under root (disabled by defa…
2 parents 28f712b + b7d8482 commit cb60d36

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,21 @@ TODO
152152
| enable_organization_runners | n/a | `bool` | n/a | yes |
153153
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
154154
| github_app | GitHub app parameters, see your github aapp. Ensure the key is base64 encoded. | <pre>object({<br> key_base64 = string<br> id = string<br> client_id = string<br> client_secret = string<br> webhook_secret = string<br> })</pre> | n/a | yes |
155-
| 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 |
156-
| vpc_id | The VPC for security groups of the action runners. | `string` | n/a | yes |
155+
| instance_profile_path | The path that will be added to the instance_profile, if not set the environment name will be used. | `string` | `null` | no |
157156
| minimum_running_time_in_minutes | The time an ec2 action runner should be running at minium before terminated if non busy. | `number` | `5` | no |
157+
| role_path | The path that will be added to role path for created roles, if not set the environment name will be used. | `string` | `null` | no |
158+
| role_permissions_boundary | Permissions boundary that will be added to the created roles. | `string` | `null` | no |
159+
| runner_as_root | Run the action runner under the root user. | `bool` | `false` | no |
158160
| runner_binaries_syncer_lambda_timeout | Time out of the binaries sync lambda in seconds. | `number` | `300` | no |
159161
| runner_binaries_syncer_lambda_zip | File location of the binaries sync lambda zip file. | `string` | `null` | no |
160162
| runner_extra_labels | Extra labels for the runners (GitHub). Separate each label by a comma | `string` | `""` | no |
161163
| runners_lambda_zip | File location of the lambda zip file for scaling runners. | `string` | `null` | no |
162164
| runners_scale_down_lambda_timeout | Time out for the scale up lambda in seconds. | `number` | `60` | no |
163165
| runners_scale_up_lambda_timeout | Time out for the scale down lambda in seconds. | `number` | `60` | no |
164166
| scale_down_schedule_expression | Scheduler expression to check every x for scale down. | `string` | `"cron(*/5 * * * ? *)"` | no |
167+
| 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 |
165168
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
169+
| vpc_id | The VPC for security groups of the action runners. | `string` | n/a | yes |
166170
| webhook_lambda_timeout | Time out of the webhook lambda in seconds. | `number` | `10` | no |
167171
| webhook_lambda_zip | File location of the wehbook lambda zip file. | `string` | `null` | no |
168172

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module "runners" {
5858
scale_down_schedule_expression = var.scale_down_schedule_expression
5959
minimum_running_time_in_minutes = var.minimum_running_time_in_minutes
6060
runner_extra_labels = var.runner_extra_labels
61+
runner_as_root = var.runner_as_root
6162

6263
lambda_zip = var.runners_lambda_zip
6364
lambda_timeout_scale_up = var.runners_scale_up_lambda_timeout

modules/runners/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ resource "aws_launch_template" "runner" {
7878
pre_install = var.userdata_pre_install
7979
post_install = var.userdata_post_install
8080
s3_location_runner_distribution = var.s3_location_runner_binaries
81+
service_user = var.runner_as_root ? "root" : "ec2-user"
8182
}))
8283

8384
tags = local.tags

modules/runners/templates/user-data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export RUNNER_ALLOW_RUNASROOT=1
3535
./config.sh --unattended --name $INSTANCE_ID --work "_work" $CONFIG
3636

3737
chown -R ec2-user:ec2-user .
38-
./svc.sh install ec2-user
38+
./svc.sh install ${service_user}
3939

4040
${post_install}
4141

modules/runners/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,8 @@ variable "instance_profile_path" {
168168
default = null
169169
}
170170

171+
variable "runner_as_root" {
172+
description = "Run the action runner under the root user."
173+
type = bool
174+
default = false
175+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,9 @@ variable "instance_profile_path" {
119119
type = string
120120
default = null
121121
}
122+
123+
variable "runner_as_root" {
124+
description = "Run the action runner under the root user."
125+
type = bool
126+
default = false
127+
}

0 commit comments

Comments
 (0)