Skip to content

Commit 17f3de3

Browse files
committed
feat(logging): add log_class parameter to runner log files configuration
1 parent 1f9805d commit 17f3de3

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Join our discord community via [this invite link](https://discord.gg/bxgXW8jJGh)
197197
| <a name="input_runner_hook_job_completed"></a> [runner\_hook\_job\_completed](#input\_runner\_hook\_job\_completed) | Script to be ran in the runner environment at the end of every job | `string` | `""` | no |
198198
| <a name="input_runner_hook_job_started"></a> [runner\_hook\_job\_started](#input\_runner\_hook\_job\_started) | Script to be ran in the runner environment at the beginning of every job | `string` | `""` | no |
199199
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |
200-
| <a name="input_runner_log_files"></a> [runner\_log\_files](#input\_runner\_log\_files) | (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. | <pre>list(object({<br/> log_group_name = string<br/> prefix_log_group = bool<br/> file_path = string<br/> log_stream_name = string<br/> }))</pre> | `null` | no |
200+
| <a name="input_runner_log_files"></a> [runner\_log\_files](#input\_runner\_log\_files) | (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. | <pre>list(object({<br/> log_group_name = string<br/> prefix_log_group = bool<br/> file_path = string<br/> log_stream_name = string<br/> log_class = optional(string, "STANDARD")<br/> }))</pre> | `null` | no |
201201
| <a name="input_runner_metadata_options"></a> [runner\_metadata\_options](#input\_runner\_metadata\_options) | Metadata options for the ec2 runner instances. By default, the module uses metadata tags for bootstrapping the runner, only disable `instance_metadata_tags` when using custom scripts for starting the runner. | `map(any)` | <pre>{<br/> "http_endpoint": "enabled",<br/> "http_put_response_hop_limit": 1,<br/> "http_tokens": "required",<br/> "instance_metadata_tags": "enabled"<br/>}</pre> | no |
202202
| <a name="input_runner_name_prefix"></a> [runner\_name\_prefix](#input\_runner\_name\_prefix) | The prefix used for the GitHub runner name. The prefix will be used in the default start script to prefix the instance name when register the runner in GitHub. The value is available via an EC2 tag 'ghr:runner\_name\_prefix'. | `string` | `""` | no |
203203
| <a name="input_runner_os"></a> [runner\_os](#input\_runner\_os) | The EC2 Operating System type to use for action runner instances (linux,windows). | `string` | `"linux"` | no |

modules/multi-runner/README.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

modules/multi-runner/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ variable "multi_runner_config" {
152152
prefix_log_group = bool
153153
file_path = string
154154
log_stream_name = string
155+
log_class = optional(string, "STANDARD")
155156
})), null)
156157
block_device_mappings = optional(list(object({
157158
delete_on_termination = optional(bool, true)

modules/runners/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ yarn run dist
213213
| <a name="input_runner_hook_job_started"></a> [runner\_hook\_job\_started](#input\_runner\_hook\_job\_started) | Script to be ran in the runner environment at the beginning of every job | `string` | `""` | no |
214214
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |
215215
| <a name="input_runner_labels"></a> [runner\_labels](#input\_runner\_labels) | All the labels for the runners (GitHub) including the default one's(e.g: self-hosted, linux, x64, label1, label2). Separate each label by a comma | `list(string)` | n/a | yes |
216-
| <a name="input_runner_log_files"></a> [runner\_log\_files](#input\_runner\_log\_files) | (optional) List of logfiles to send to CloudWatch, will only be used if `enable_cloudwatch_agent` is set to true. Object description: `log_group_name`: Name of the log group, `prefix_log_group`: If true, the log group name will be prefixed with `/github-self-hosted-runners/<var.prefix>`, `file_path`: path to the log file, `log_stream_name`: name of the log stream. | <pre>list(object({<br/> log_group_name = string<br/> prefix_log_group = bool<br/> file_path = string<br/> log_stream_name = string<br/> }))</pre> | `null` | no |
216+
| <a name="input_runner_log_files"></a> [runner\_log\_files](#input\_runner\_log\_files) | (optional) List of logfiles to send to CloudWatch, will only be used if `enable_cloudwatch_agent` is set to true. Object description: `log_group_name`: Name of the log group, `prefix_log_group`: If true, the log group name will be prefixed with `/github-self-hosted-runners/<var.prefix>`, `file_path`: path to the log file, `log_stream_name`: name of the log stream, `log_class`: The log class of the log group. Valid values are `STANDARD` or `INFREQUENT_ACCESS`. Defaults to `STANDARD`. | <pre>list(object({<br/> log_group_name = string<br/> prefix_log_group = bool<br/> file_path = string<br/> log_stream_name = string<br/> log_class = optional(string, "STANDARD")<br/> }))</pre> | `null` | no |
217217
| <a name="input_runner_name_prefix"></a> [runner\_name\_prefix](#input\_runner\_name\_prefix) | The prefix used for the GitHub runner name. The prefix will be used in the default start script to prefix the instance name when register the runner in GitHub. The value is available via an EC2 tag 'ghr:runner\_name\_prefix'. | `string` | `""` | no |
218218
| <a name="input_runner_os"></a> [runner\_os](#input\_runner\_os) | The EC2 Operating System type to use for action runner instances (linux,windows). | `string` | `"linux"` | no |
219219
| <a name="input_runner_run_as"></a> [runner\_run\_as](#input\_runner\_run\_as) | Run the GitHub actions agent as user. | `string` | `"ec2-user"` | no |

modules/runners/logging.tf

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,40 @@ locals {
77
"prefix_log_group" : true,
88
"file_path" : "/var/log/messages",
99
"log_group_name" : "messages",
10-
"log_stream_name" : "{instance_id}"
10+
"log_stream_name" : "{instance_id}",
11+
"log_class" : "STANDARD"
1112
},
1213
{
1314
"log_group_name" : "user_data",
1415
"prefix_log_group" : true,
1516
"file_path" : var.runner_os == "windows" ? "C:/UserData.log" : "/var/log/user-data.log",
16-
"log_stream_name" : "{instance_id}"
17+
"log_stream_name" : "{instance_id}",
18+
"log_class" : "STANDARD"
1719
},
1820
{
1921
"log_group_name" : "runner",
2022
"prefix_log_group" : true,
2123
"file_path" : var.runner_os == "windows" ? "C:/actions-runner/_diag/Runner_*.log" : "/opt/actions-runner/_diag/Runner_**.log",
22-
"log_stream_name" : "{instance_id}"
24+
"log_stream_name" : "{instance_id}",
25+
"log_class" : "STANDARD"
2326
},
2427
{
2528
"log_group_name" : "runner-startup",
2629
"prefix_log_group" : true,
2730
"file_path" : var.runner_os == "windows" ? "C:/runner-startup.log" : "/var/log/runner-startup.log",
28-
"log_stream_name" : "{instance_id}"
31+
"log_stream_name" : "{instance_id}",
32+
"log_class" : "STANDARD"
2933
}
3034
]
3135
)
3236
logfiles = var.enable_cloudwatch_agent ? [for l in local.runner_log_files : {
3337
"log_group_name" : l.prefix_log_group ? "/github-self-hosted-runners/${var.prefix}/${l.log_group_name}" : "/${l.log_group_name}"
3438
"log_stream_name" : l.log_stream_name
3539
"file_path" : l.file_path
40+
"log_class" : try(l.log_class, "STANDARD")
3641
}] : []
3742

38-
loggroups_names = distinct([for l in local.logfiles : l.log_group_name])
43+
loggroups = distinct([for l in local.logfiles : { name = l.log_group_name, log_class = l.log_class }])
3944

4045
}
4146

@@ -51,10 +56,11 @@ resource "aws_ssm_parameter" "cloudwatch_agent_config_runner" {
5156
}
5257

5358
resource "aws_cloudwatch_log_group" "gh_runners" {
54-
count = length(local.loggroups_names)
55-
name = local.loggroups_names[count.index]
59+
for_each = { for lg in local.loggroups : lg.name => lg }
60+
name = each.value.name
5661
retention_in_days = var.logging_retention_in_days
5762
kms_key_id = var.logging_kms_key_id
63+
log_group_class = each.value.log_class
5864
tags = local.tags
5965
}
6066

modules/runners/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,13 @@ variable "cloudwatch_config" {
395395
}
396396

397397
variable "runner_log_files" {
398-
description = "(optional) List of logfiles to send to CloudWatch, will only be used if `enable_cloudwatch_agent` is set to true. Object description: `log_group_name`: Name of the log group, `prefix_log_group`: If true, the log group name will be prefixed with `/github-self-hosted-runners/<var.prefix>`, `file_path`: path to the log file, `log_stream_name`: name of the log stream."
398+
description = "(optional) List of logfiles to send to CloudWatch, will only be used if `enable_cloudwatch_agent` is set to true. Object description: `log_group_name`: Name of the log group, `prefix_log_group`: If true, the log group name will be prefixed with `/github-self-hosted-runners/<var.prefix>`, `file_path`: path to the log file, `log_stream_name`: name of the log stream, `log_class`: The log class of the log group. Valid values are `STANDARD` or `INFREQUENT_ACCESS`. Defaults to `STANDARD`."
399399
type = list(object({
400400
log_group_name = string
401401
prefix_log_group = bool
402402
file_path = string
403403
log_stream_name = string
404+
log_class = optional(string, "STANDARD")
404405
}))
405406
default = null
406407
}

variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ variable "runner_log_files" {
491491
prefix_log_group = bool
492492
file_path = string
493493
log_stream_name = string
494+
log_class = optional(string, "STANDARD")
494495
}))
495496
default = null
496497
}

0 commit comments

Comments
 (0)