Skip to content

Commit 0c79ffe

Browse files
committed
feat(logging): add log_class parameter to runner log files configuration
1 parent 07bd193 commit 0c79ffe

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

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/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)