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

Commit 94779f8

Browse files
author
Király Ádám
authored
feat(runner): Ability to disable default runner security group creation (#1718)
* Implement optional disable for the managed security group creation. * Create security group disablement variable. * Fix launch template creation issue. * Fix formatting error.
1 parent 6282351 commit 94779f8

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ In case the setup does not work as intended follow the trace of events:
402402
| <a name="input_delay_webhook_event"></a> [delay\_webhook\_event](#input\_delay\_webhook\_event) | The number of seconds the event accepted by the webhook is invisible on the queue before the scale up lambda will receive the event. | `number` | `30` | no |
403403
| <a name="input_enable_cloudwatch_agent"></a> [enable\_cloudwatch\_agent](#input\_enable\_cloudwatch\_agent) | Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
404404
| <a name="input_enable_ephemeral_runners"></a> [enable\_ephemeral\_runners](#input\_enable\_ephemeral\_runners) | Enable ephemeral runners, runners will only be used once. | `bool` | `false` | no |
405+
| <a name="input_enable_managed_runner_security_group"></a> [enable\_managed\_runner\_security\_group](#inputenable\_managed\_runner\_security\_group) | Enabling the default managed security group creation. Unmanaged security groups can be specified via `runner_additional_security_group_ids`. | `bool` | `true` | no |
405406
| <a name="input_enable_organization_runners"></a> [enable\_organization\_runners](#input\_enable\_organization\_runners) | Register runners to organization, instead of repo level | `bool` | `false` | no |
406407
| <a name="input_enable_ssm_on_runners"></a> [enable\_ssm\_on\_runners](#input\_enable\_ssm\_on\_runners) | Enable to allow access the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances. | `bool` | `false` | no |
407408
| <a name="input_enabled_userdata"></a> [enabled\_userdata](#input\_enabled\_userdata) | Should the userdata script be enabled for the runner. Set this to false if you are using your own prebuilt AMI | `bool` | `true` | no |

Diff for: main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module "runners" {
107107
github_app_parameters = local.github_app_parameters
108108
enable_organization_runners = var.enable_organization_runners
109109
enable_ephemeral_runners = var.enable_ephemeral_runners
110+
enable_managed_runner_security_group = var.enable_managed_runner_security_group
110111
scale_down_schedule_expression = var.scale_down_schedule_expression
111112
minimum_running_time_in_minutes = var.minimum_running_time_in_minutes
112113
runner_boot_time_in_minutes = var.runner_boot_time_in_minutes

Diff for: modules/runners/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ yarn run dist
122122
| <a name="input_egress_rules"></a> [egress\_rules](#input\_egress\_rules) | List of egress rules for the GitHub runner instances. | <pre>list(object({<br> cidr_blocks = list(string)<br> ipv6_cidr_blocks = list(string)<br> prefix_list_ids = list(string)<br> from_port = number<br> protocol = string<br> security_groups = list(string)<br> self = bool<br> to_port = number<br> description = string<br> }))</pre> | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": null,<br> "from_port": 0,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "prefix_list_ids": null,<br> "protocol": "-1",<br> "security_groups": null,<br> "self": null,<br> "to_port": 0<br> }<br>]</pre> | no |
123123
| <a name="input_enable_cloudwatch_agent"></a> [enable\_cloudwatch\_agent](#input\_enable\_cloudwatch\_agent) | Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
124124
| <a name="input_enable_ephemeral_runners"></a> [enable\_ephemeral\_runners](#input\_enable\_ephemeral\_runners) | Enable ephemeral runners, runners will only be used once. | `bool` | `false` | no |
125+
| <a name="input_enable_managed_runner_security_group"></a> [enable\_managed\_runner\_security\_group](#inputenable\_managed\_runner\_security\_group) | Enabling the default managed security group creation. Unmanaged security groups can be specified via `runner_additional_security_group_ids`. | `bool` | `true` | no |
125126
| <a name="input_enable_organization_runners"></a> [enable\_organization\_runners](#input\_enable\_organization\_runners) | n/a | `bool` | n/a | yes |
126127
| <a name="input_enable_ssm_on_runners"></a> [enable\_ssm\_on\_runners](#input\_enable\_ssm\_on\_runners) | Enable to allow access to the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances. | `bool` | n/a | yes |
127128
| <a name="input_enabled_userdata"></a> [enabled\_userdata](#input\_enabled\_userdata) | Should the userdata script be enabled for the runner. Set this to false if you are using your own prebuilt AMI | `bool` | `true` | no |

Diff for: modules/runners/main.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ resource "aws_launch_template" "runner" {
8888
key_name = var.key_name
8989

9090
vpc_security_group_ids = compact(concat(
91-
[aws_security_group.runner_sg.id],
91+
var.enable_managed_runner_security_group ? [aws_security_group.runner_sg[0].id] : [],
9292
var.runner_additional_security_group_ids,
9393
))
9494

@@ -136,6 +136,7 @@ resource "aws_launch_template" "runner" {
136136
}
137137

138138
resource "aws_security_group" "runner_sg" {
139+
count = var.enable_managed_runner_security_group ? 1 : 0
139140
name_prefix = "${var.environment}-github-actions-runner-sg"
140141
description = "Github Actions Runner security group"
141142

Diff for: modules/runners/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,12 @@ variable "enable_cloudwatch_agent" {
318318
default = true
319319
}
320320

321+
variable "enable_managed_runner_security_group" {
322+
description = "Enabling the default managed security group creation. Unmanaged security groups can be specified via `runner_additional_security_group_ids`."
323+
type = bool
324+
default = true
325+
}
326+
321327
variable "cloudwatch_config" {
322328
description = "(optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details."
323329
type = string

Diff for: variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,12 @@ variable "enable_ephemeral_runners" {
501501
default = false
502502
}
503503

504+
variable "enable_managed_runner_security_group" {
505+
description = "Enabling the default managed security group creation. Unmanaged security groups can be specified via `runner_additional_security_group_ids`."
506+
type = bool
507+
default = true
508+
}
509+
504510
variable "runner_os" {
505511
description = "The EC2 Operating System type to use for action runner instances (linux,windows)."
506512
type = string

0 commit comments

Comments
 (0)