Skip to content

Commit c415a6f

Browse files
committed
feat(logging): add log_class parameter to all CloudWatch log groups
Extends the log_class parameter to all CloudWatch log groups managed by the module, allowing users to set INFREQUENT_ACCESS class to reduce costs. Log groups updated: - runner-binaries-syncer (syncer) - ami-housekeeper - runners (scale-down, scale-up, ssm-housekeeper) - runners/pool - webhook/direct - webhook/eventbridge (webhook, dispatcher) - lambda module (shared) - termination-watcher - multi-runner (passthrough to all submodules) Defaults to STANDARD for backward compatibility.
1 parent 65cfbb3 commit c415a6f

29 files changed

+96
-0
lines changed

main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ module "webhook" {
136136
tracing_config = var.tracing_config
137137
logging_retention_in_days = var.logging_retention_in_days
138138
logging_kms_key_id = var.logging_kms_key_id
139+
log_class = var.log_class
139140

140141
role_path = var.role_path
141142
role_permissions_boundary = var.role_permissions_boundary
@@ -227,6 +228,7 @@ module "runners" {
227228
tracing_config = var.tracing_config
228229
logging_retention_in_days = var.logging_retention_in_days
229230
logging_kms_key_id = var.logging_kms_key_id
231+
log_class = var.log_class
230232
enable_cloudwatch_agent = var.enable_cloudwatch_agent
231233
cloudwatch_config = var.cloudwatch_config
232234
runner_log_files = var.runner_log_files
@@ -306,6 +308,7 @@ module "runner_binaries" {
306308
tracing_config = var.tracing_config
307309
logging_retention_in_days = var.logging_retention_in_days
308310
logging_kms_key_id = var.logging_kms_key_id
311+
log_class = var.log_class
309312

310313
state_event_rule_binaries_syncer = var.state_event_rule_binaries_syncer
311314
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
@@ -348,6 +351,7 @@ module "ami_housekeeper" {
348351

349352
logging_retention_in_days = var.logging_retention_in_days
350353
logging_kms_key_id = var.logging_kms_key_id
354+
log_class = var.log_class
351355
log_level = var.log_level
352356

353357
role_path = var.role_path
@@ -369,6 +373,7 @@ locals {
369373
subnet_ids = var.lambda_subnet_ids
370374
lambda_tags = var.lambda_tags
371375
log_level = var.log_level
376+
log_class = var.log_class
372377
logging_kms_key_id = var.logging_kms_key_id
373378
logging_retention_in_days = var.logging_retention_in_days
374379
role_path = var.role_path

modules/ami-housekeeper/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ resource "aws_cloudwatch_log_group" "ami_housekeeper" {
5151
name = "/aws/lambda/${aws_lambda_function.ami_housekeeper.function_name}"
5252
retention_in_days = var.logging_retention_in_days
5353
kms_key_id = var.logging_kms_key_id
54+
log_group_class = var.log_class
5455
tags = var.tags
5556
}
5657

modules/ami-housekeeper/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ variable "logging_kms_key_id" {
5454
default = null
5555
}
5656

57+
variable "log_class" {
58+
description = "The log class of the CloudWatch log group. Valid values are `STANDARD` or `INFREQUENT_ACCESS`."
59+
type = string
60+
default = "STANDARD"
61+
62+
validation {
63+
condition = contains(["STANDARD", "INFREQUENT_ACCESS"], var.log_class)
64+
error_message = "`log_class` must be either `STANDARD` or `INFREQUENT_ACCESS`."
65+
}
66+
}
67+
5768
variable "lambda_subnet_ids" {
5869
description = "List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`."
5970
type = list(string)

modules/lambda/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ resource "aws_cloudwatch_log_group" "main" {
5656
name = "/aws/lambda/${aws_lambda_function.main.function_name}"
5757
retention_in_days = var.lambda.logging_retention_in_days
5858
kms_key_id = var.lambda.logging_kms_key_id
59+
log_group_class = var.lambda.log_class
5960
tags = var.lambda.tags
6061
}
6162

modules/lambda/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ variable "lambda" {
1111
`log_level`: Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'.
1212
`logging_kms_key_id`: Specifies the kms key id to encrypt the logs with
1313
`logging_retention_in_days`: Specifies the number of days you want to retain log events for the lambda log group. Possible values are: 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653.
14+
`log_class`: The log class of the CloudWatch log group. Valid values are `STANDARD` or `INFREQUENT_ACCESS`.
1415
`memory_size`: Memory size limit in MB of the lambda.
1516
`metrics_namespace`: Namespace for the metrics emitted by the lambda.
1617
`name`: The name of the lambda function.
@@ -35,6 +36,7 @@ variable "lambda" {
3536
handler = string
3637
lambda_tags = optional(map(string), {})
3738
log_level = optional(string, "info")
39+
log_class = optional(string, "STANDARD")
3840
logging_kms_key_id = optional(string, null)
3941
logging_retention_in_days = optional(number, 180)
4042
memory_size = optional(number, 256)

modules/multi-runner/ami-housekeeper.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module "ami_housekeeper" {
2424

2525
logging_retention_in_days = var.logging_retention_in_days
2626
logging_kms_key_id = var.logging_kms_key_id
27+
log_class = var.log_class
2728
log_level = var.log_level
2829

2930
role_path = var.role_path

modules/multi-runner/runner-binaries.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ module "runner_binaries" {
2222
tracing_config = var.tracing_config
2323
logging_retention_in_days = var.logging_retention_in_days
2424
logging_kms_key_id = var.logging_kms_key_id
25+
log_class = var.log_class
2526
state_event_rule_binaries_syncer = var.state_event_rule_binaries_syncer
2627

2728
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration

modules/multi-runner/runners.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ module "runners" {
7676
tracing_config = var.tracing_config
7777
logging_retention_in_days = var.logging_retention_in_days
7878
logging_kms_key_id = var.logging_kms_key_id
79+
log_class = var.log_class
7980
enable_cloudwatch_agent = each.value.runner_config.enable_cloudwatch_agent
8081
cloudwatch_config = try(coalesce(each.value.runner_config.cloudwatch_config, var.cloudwatch_config), null)
8182
runner_log_files = each.value.runner_config.runner_log_files

modules/multi-runner/termination-watcher.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ locals {
99
security_group_ids = var.lambda_security_group_ids
1010
subnet_ids = var.lambda_subnet_ids
1111
log_level = var.log_level
12+
log_class = var.log_class
1213
logging_kms_key_id = var.logging_kms_key_id
1314
logging_retention_in_days = var.logging_retention_in_days
1415
role_path = var.role_path

modules/multi-runner/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,17 @@ variable "logging_kms_key_id" {
327327
default = null
328328
}
329329

330+
variable "log_class" {
331+
description = "The log class of the CloudWatch log groups. Valid values are `STANDARD` or `INFREQUENT_ACCESS`."
332+
type = string
333+
default = "STANDARD"
334+
335+
validation {
336+
condition = contains(["STANDARD", "INFREQUENT_ACCESS"], var.log_class)
337+
error_message = "`log_class` must be either `STANDARD` or `INFREQUENT_ACCESS`."
338+
}
339+
}
340+
330341
variable "lambda_s3_bucket" {
331342
description = "S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly."
332343
type = string

0 commit comments

Comments
 (0)