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

Commit 142bb61

Browse files
npalmphilips-labs-pr|bot
and
philips-labs-pr|bot
authored
feat!: Enable eventbridge by default (#4320)
Promote eventbridge to standard. The eventbridge can be disable by setting: ```hcl eventbridge = { enable = false } ``` --------- Co-authored-by: philips-labs-pr|bot <philips-labs-pr[bot]@users.noreply.github.com>
1 parent 7171215 commit 142bb61

File tree

6 files changed

+14
-78
lines changed

6 files changed

+14
-78
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Talk to the forestkeepers in the `runners-channel` on Slack.
149149
| <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` | `false` | no |
150150
| <a name="input_enable_user_data_debug_logging_runner"></a> [enable\_user\_data\_debug\_logging\_runner](#input\_enable\_user\_data\_debug\_logging\_runner) | Option to enable debug logging for user-data, this logs all secrets as well. | `bool` | `false` | no |
151151
| <a name="input_enable_userdata"></a> [enable\_userdata](#input\_enable\_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 |
152-
| <a name="input_eventbridge"></a> [eventbridge](#input\_eventbridge) | Enable the use of EventBridge by the module. By enabling this feature events will be put on the EventBridge by the webhook instead of directly dispatching to queues for scaling.<br/><br/> `enable`: Enable the EventBridge feature.<br/> `accept_events`: List can be used to only allow specific events to be putted on the EventBridge. By default all events, empty list will be be interpreted as all events. | <pre>object({<br/> enable = optional(bool, false)<br/> accept_events = optional(list(string), null)<br/> })</pre> | `{}` | no |
152+
| <a name="input_eventbridge"></a> [eventbridge](#input\_eventbridge) | Enable the use of EventBridge by the module. By enabling this feature events will be put on the EventBridge by the webhook instead of directly dispatching to queues for scaling.<br/><br/> `enable`: Enable the EventBridge feature.<br/> `accept_events`: List can be used to only allow specific events to be putted on the EventBridge. By default all events, empty list will be be interpreted as all events. | <pre>object({<br/> enable = optional(bool, true)<br/> accept_events = optional(list(string), null)<br/> })</pre> | `{}` | no |
153153
| <a name="input_ghes_ssl_verify"></a> [ghes\_ssl\_verify](#input\_ghes\_ssl\_verify) | GitHub Enterprise SSL verification. Set to 'false' when custom certificate (chains) is used for GitHub Enterprise Server (insecure). | `bool` | `true` | no |
154154
| <a name="input_ghes_url"></a> [ghes\_url](#input\_ghes\_url) | GitHub Enterprise Server URL. Example: https://github.internal.co - DO NOT SET IF USING PUBLIC GITHUB | `string` | `null` | no |
155155
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub app parameters, see your github app. Ensure the key is the base64-encoded `.pem` file (the output of `base64 app.private-key.pem`, not the content of `private-key.pem`). | <pre>object({<br/> key_base64 = string<br/> id = string<br/> webhook_secret = string<br/> })</pre> | n/a | yes |

docs/configuration.md

+4-60
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ To be able to support a number of use-cases, the module has quite a lot of confi
66

77
- Org vs Repo level. You can configure the module to connect the runners in GitHub on an org level and share the runners in your org, or set the runners on repo level and the module will install the runner to the repo. There can be multiple repos but runners are not shared between repos.
88
- Multi-Runner module. This modules allows you to create multiple runner configurations with a single webhook and single GitHub App to simplify deployment of different types of runners. Check the detailed module [documentation](modules/public/multi-runner.md) for more information or checkout the [multi-runner example](examples/multi-runner.md).
9-
- Webhook mode, the module can be deployed in `direct` mode or `EventBridge` (Experimental) mode. The `direct` mode is the default and will directly distribute to SQS for the scale-up lambda. The `EventBridge` mode will publish the events to a eventbus, the rule then directs the received events to a dispatch lambda. The dispatch lambda will send the event to the SQS queue. The `EventBridge` mode is useful when you want to have more control over the events and potentially filter them. The `EventBridge` mode is disabled by default. An example of what the `EventBridge` mode could be used for is building a data lake, build metrics, act on `workflow_job` job started events, etc.
9+
- Webhook mode, the module can be deployed in `direct` mode or `EventBridge` (Experimental) mode. The `direct` mode is the default and will directly distribute to SQS for the scale-up lambda. The `EventBridge` mode will publish the events to a eventbus, the rule then directs the received events to a dispatch lambda. The dispatch lambda will send the event to the SQS queue. The `EventBridge` mode is the default and allows to have more control over the events and potentially filter them. The `EventBridge` mode can be disabled, messages are sent directed to queues in that case. An example of what the `EventBridge` mode could be used for is building a data lake, build metrics, act on `workflow_job` job started events, etc.
1010
- Linux vs Windows. You can configure the OS types linux and win. Linux will be used by default.
1111
- Re-use vs Ephemeral. By default runners are re-used, until detected idle. Once idle they will be removed from the pool. To improve security we are introducing ephemeral runners. Those runners are only used for one job. Ephemeral runners only work in combination with the workflow job event. For ephemeral runners the lambda requests a JIT (just in time) configuration via the GitHub API to register the runner. [JIT configuration](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-just-in-time-runners) is limited to ephemeral runners (and currently not supported by GHES). For non-ephemeral runners, a registration token is always requested. In both cases the configuration is made available to the instance via the same SSM parameter. To disable JIT configuration for ephemeral runners set `enable_jit_config` to `false`. We also suggest using a pre-build AMI to improve the start time of jobs for ephemeral runners.
1212
- Job retry (**Beta**). By default the scale-up lambda will discard the message when it is handled. Meaning in the ephemeral use-case an instance is created. The created runner will ask GitHub for a job, no guarantee it will run the job for which it was scaling. Result could be that with small system hick-up the job is keeping waiting for a runner. Enable a pool (org runners) is one option to avoid this problem. Another option is to enable the job retry function. Which will retry the job after a delay for a configured number of times.
@@ -263,9 +263,9 @@ Below an example of the the log messages created.
263263

264264
### EventBridge
265265

266-
This module can be deployed in using the mode `EventBridge` (Experimental). The `EventBridge` mode will publish an event to a eventbus. Within the eventbus, there is a target rule set, sending events to the dispatch lambda. The `EventBridge` mode is disabled by default.
266+
This module can be deployed in using the mode `EventBridge`. The `EventBridge` mode will publish an event to a eventbus. Within the eventbus, there is a target rule set, sending events to the dispatch lambda. The `EventBridge` mode is enabled by default.
267267

268-
Example to use the EventBridge:
268+
Example to extend the EventBridge:
269269

270270
```hcl
271271
@@ -274,7 +274,7 @@ module "runners" {
274274
275275
...
276276
eventbridge = {
277-
enable = true
277+
enable = false
278278
}
279279
...
280280
}
@@ -332,61 +332,5 @@ resource "aws_iam_role_policy" "event_rule_firehose_role" {
332332
}
333333
```
334334

335-
### Queue to publish workflow job events
336-
337-
!!! warning "Removed
338-
339-
This feaTure will be removed since we introducing the EventBridge. Same functionality can be implemented by adding a rule to the EventBridge to forward `workflow_job` events to the SQS queue.
340-
341-
Below an example how you can sent all `workflow_job` with action `in_progress` to a SQS queue.
342-
343-
```hcl
344-
345-
resource "aws_cloudwatch_event_rule" "workflow_job_in_progress" {
346-
name = "workflow-job-in-progress"
347-
event_bus_name = modules.runners.webhook.eventbridge.name # The name of the event bus output by the module
348-
349-
event_pattern = <<EOF
350-
{
351-
"detail-type": ["workflow_job"],
352-
"detail": {
353-
"action": ["in_progress"]
354-
}
355-
}
356-
EOF
357-
}
358-
359-
resource "aws_sqs_queue" "workflow_job_in_progress" {
360-
name = "workflow_job_in_progress
361-
}
362-
363-
resource "aws_sqs_queue_policy" "workflow_job_in_progress" {
364-
queue_url = aws_sqs_queue.workflow_job_in_progress.id
365-
policy = data.aws_iam_policy_document.sqs_policy.json
366-
}
367-
368-
data "aws_iam_policy_document" "sqs_policy" {
369-
statement {
370-
sid = "AllowFromEventBridge"
371-
actions = ["sqs:SendMessage"]
372-
373-
principals {
374-
type = "Service"
375-
identifiers = ["events.amazonaws.com"]
376-
}
377-
378-
resources = [aws_sqs_queue.workflow_job_in_progress.arn]
379-
380-
condition {
381-
test = "ArnEquals"
382-
variable = "aws:SourceArn"
383-
values = [aws_cloudwatch_event_rule.workflow_job_in_progress.arn]
384-
}
385-
}
386-
}
387-
388-
```
389-
390-
391335

392336
NOTE: By default, a runner AMI update requires a re-apply of this terraform config (the runner AMI ID is looked up by a terraform data source). To avoid this, you can use `ami_id_ssm_parameter_name` to have the scale-up lambda dynamically lookup the runner AMI ID from an SSM parameter at instance launch time. Said SSM parameter is managed outside of this module (e.g. by a runner AMI build workflow).

examples/default/main.tf

+4-6
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,10 @@ module "runners" {
9292
# prefix GitHub runners with the environment name
9393
runner_name_prefix = "${local.environment}_"
9494

95-
# webhook supports two modes, either direct or via the eventbridge, uncomment to enable eventbridge
96-
# eventbridge = {
97-
# enable = true
98-
# # adjust the allow events to only allow specific events, like workflow_job
99-
# # allowed_events = ['workflow_job']
100-
# }
95+
# by default eventbridge is used, see multi-runner example. Here we disable the eventbridge
96+
eventbridge = {
97+
enable = false
98+
}
10199

102100
# Enable debug logging for the lambda functions
103101
# log_level = "debug"

modules/multi-runner/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ module "multi-runner" {
128128
| <a name="input_cloudwatch_config"></a> [cloudwatch\_config](#input\_cloudwatch\_config) | (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. | `string` | `null` | no |
129129
| <a name="input_enable_ami_housekeeper"></a> [enable\_ami\_housekeeper](#input\_enable\_ami\_housekeeper) | Option to disable the lambda to clean up old AMIs. | `bool` | `false` | no |
130130
| <a name="input_enable_managed_runner_security_group"></a> [enable\_managed\_runner\_security\_group](#input\_enable\_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 |
131-
| <a name="input_eventbridge"></a> [eventbridge](#input\_eventbridge) | Enable the use of EventBridge by the module. By enabling this feature events will be put on the EventBridge by the webhook instead of directly dispatching to queues for scaling. | <pre>object({<br/> enable = optional(bool, false)<br/> accept_events = optional(list(string), [])<br/> })</pre> | `{}` | no |
131+
| <a name="input_eventbridge"></a> [eventbridge](#input\_eventbridge) | Enable the use of EventBridge by the module. By enabling this feature events will be put on the EventBridge by the webhook instead of directly dispatching to queues for scaling. | <pre>object({<br/> enable = optional(bool, true)<br/> accept_events = optional(list(string), [])<br/> })</pre> | `{}` | no |
132132
| <a name="input_ghes_ssl_verify"></a> [ghes\_ssl\_verify](#input\_ghes\_ssl\_verify) | GitHub Enterprise SSL verification. Set to 'false' when custom certificate (chains) is used for GitHub Enterprise Server (insecure). | `bool` | `true` | no |
133133
| <a name="input_ghes_url"></a> [ghes\_url](#input\_ghes\_url) | GitHub Enterprise Server URL. Example: https://github.internal.co - DO NOT SET IF USING PUBLIC GITHUB | `string` | `null` | no |
134134
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub app parameters, see your github app. Ensure the key is the base64-encoded `.pem` file (the output of `base64 app.private-key.pem`, not the content of `private-key.pem`). | <pre>object({<br/> key_base64 = string<br/> id = string<br/> webhook_secret = string<br/> })</pre> | n/a | yes |
135135
| <a name="input_instance_profile_path"></a> [instance\_profile\_path](#input\_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 |
136-
| <a name="input_instance_termination_watcher"></a> [instance\_termination\_watcher](#input\_instance\_termination\_watcher) | Configuration for the spot termination watcher lambda function. This feature is Beta, changes will not trigger a major release as long in beta.<br/><br/>`enable`: Enable or disable the spot termination watcher.<br/>`memory_size`: Memory size linit in MB of the lambda.<br/>`s3_key`: S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas.<br/>`s3_object_version`: S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket.<br/>`timeout`: Time out of the lambda in seconds.<br/>`zip`: File location of the lambda zip file. | <pre>object({<br/> enable = optional(bool, false)<br/> enable_metrics = optional(string, null) # deprecated<br/> features = optional(object({<br/> enable_spot_termination_handler = optional(bool, true)<br/> enable_spot_termination_notification_watcher = optional(bool, true)<br/> }), {})<br/> memory_size = optional(number, null)<br/> s3_key = optional(string, null)<br/> s3_object_version = optional(string, null)<br/> timeout = optional(number, null)<br/> zip = optional(string, null)<br/> })</pre> | `{}` | no |
136+
| <a name="input_instance_termination_watcher"></a> [instance\_termination\_watcher](#input\_instance\_termination\_watcher) | Configuration for the spot termination watcher lambda function. This feature is Beta, changes will not trigger a major release as long in beta.<br/><br/>`enable`: Enable or disable the spot termination watcher.<br/>`memory_size`: Memory size linit in MB of the lambda.<br/>`s3_key`: S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas.<br/>`s3_object_version`: S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket.<br/>`timeout`: Time out of the lambda in seconds.<br/>`zip`: File location of the lambda zip file. | <pre>object({<br/> enable = optional(bool, false)<br/> features = optional(object({<br/> enable_spot_termination_handler = optional(bool, true)<br/> enable_spot_termination_notification_watcher = optional(bool, true)<br/> }), {})<br/> memory_size = optional(number, null)<br/> s3_key = optional(string, null)<br/> s3_object_version = optional(string, null)<br/> timeout = optional(number, null)<br/> zip = optional(string, null)<br/> })</pre> | `{}` | no |
137137
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Key pair name | `string` | `null` | no |
138138
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | Optional CMK Key ARN to be used for Parameter Store. | `string` | `null` | no |
139139
| <a name="input_lambda_architecture"></a> [lambda\_architecture](#input\_lambda\_architecture) | AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86\_64' functions. | `string` | `"arm64"` | no |

modules/multi-runner/variables.tf

+2-8
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,7 @@ variable "instance_termination_watcher" {
618618
EOF
619619

620620
type = object({
621-
enable = optional(bool, false)
622-
enable_metrics = optional(string, null) # deprecated
621+
enable = optional(bool, false)
623622
features = optional(object({
624623
enable_spot_termination_handler = optional(bool, true)
625624
enable_spot_termination_notification_watcher = optional(bool, true)
@@ -631,11 +630,6 @@ variable "instance_termination_watcher" {
631630
zip = optional(string, null)
632631
})
633632
default = {}
634-
635-
validation {
636-
condition = var.instance_termination_watcher.enable_metrics == null
637-
error_message = "The feature `instance_termination_watcher` is deprecated and will be removed in a future release. Please use the `termination_watcher` variable instead."
638-
}
639633
}
640634

641635
variable "lambda_tags" {
@@ -671,7 +665,7 @@ variable "metrics" {
671665
variable "eventbridge" {
672666
description = "Enable the use of EventBridge by the module. By enabling this feature events will be put on the EventBridge by the webhook instead of directly dispatching to queues for scaling."
673667
type = object({
674-
enable = optional(bool, false)
668+
enable = optional(bool, true)
675669
accept_events = optional(list(string), [])
676670
})
677671

variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ variable "eventbridge" {
946946
`accept_events`: List can be used to only allow specific events to be putted on the EventBridge. By default all events, empty list will be be interpreted as all events.
947947
EOF
948948
type = object({
949-
enable = optional(bool, false)
949+
enable = optional(bool, true)
950950
accept_events = optional(list(string), null)
951951
})
952952

0 commit comments

Comments
 (0)