Skip to content

Commit e78065d

Browse files
Brend-Smitsgithub-aws-runners-pr|bot
andcommitted
feat(logging): add log_class parameter to runner log files configuration (#5036)
This pull request updates the logging configuration by introducing support for the `log_class` property, allowing log groups to be created with either the `STANDARD` or `INFREQUENT_ACCESS` class. The change is applied throughout the configuration to ensure log groups and log files can specify their class, defaulting to `STANDARD` if not set. **Logging configuration enhancements:** * Added a `log_class` property (defaulting to `"STANDARD"`) to the `runner_log_files` and `multi_runner_config` variables in `variables.tf`, `modules/runners/variables.tf`, and `modules/multi-runner/variables.tf` to allow specifying the log group class. [[1]](diffhunk://#diff-05b5a57c136b6ff596500bcbfdcff145ef6cddea2a0e86d184d9daa9a65a288eR494) [[2]](diffhunk://#diff-23e8f44c0f21971190244acdb8a35eaa21af7578ed5f1b97bef83f1a566d979cL398-R404) [[3]](diffhunk://#diff-52d0673ff466b6445542e17038ea73a1cf41b8112f49ee57da4cebf8f0cb99c5R155) * Updated the local log file definitions in `modules/runners/logging.tf` to include the `log_class` property for each log file, defaulting to `"STANDARD"`. * Modified the CloudWatch log group resource in `modules/runners/logging.tf` to use the specified `log_class` when creating log groups, and refactored the logic to group log files by both name and class. **Documentation improvements:** * Enhanced the description of the `runner_log_files` variable to document the new `log_class` property and its valid values. --------- Signed-off-by: Brend Smits <brend.smits@philips.com> Co-authored-by: github-aws-runners-pr|bot <github-aws-runners-pr[bot]@users.noreply.github.com>
1 parent 84381ae commit e78065d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+140
-17
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Join our discord community via [this invite link](https://discord.gg/bxgXW8jJGh)
158158
| <a name="input_lambda_security_group_ids"></a> [lambda\_security\_group\_ids](#input\_lambda\_security\_group\_ids) | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no |
159159
| <a name="input_lambda_subnet_ids"></a> [lambda\_subnet\_ids](#input\_lambda\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | `[]` | no |
160160
| <a name="input_lambda_tags"></a> [lambda\_tags](#input\_lambda\_tags) | Map of tags that will be added to all the lambda function resources. Note these are additional tags to the default tags. | `map(string)` | `{}` | no |
161+
| <a name="input_log_class"></a> [log\_class](#input\_log\_class) | The log class of the CloudWatch log groups. Valid values are `STANDARD` or `INFREQUENT_ACCESS`. | `string` | `"STANDARD"` | no |
161162
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'. | `string` | `"info"` | no |
162163
| <a name="input_logging_kms_key_id"></a> [logging\_kms\_key\_id](#input\_logging\_kms\_key\_id) | Specifies the kms key id to encrypt the logs with. | `string` | `null` | no |
163164
| <a name="input_logging_retention_in_days"></a> [logging\_retention\_in\_days](#input\_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. | `number` | `180` | no |
@@ -198,7 +199,7 @@ Join our discord community via [this invite link](https://discord.gg/bxgXW8jJGh)
198199
| <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 |
199200
| <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 |
200201
| <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 |
201-
| <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 |
202+
| <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 |
202203
| <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 |
203204
| <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 |
204205
| <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 |

examples/multi-runner/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ module "runners" {
139139
# Enable debug logging for the lambda functions
140140
# log_level = "debug"
141141

142+
# Set log class to INFREQUENT_ACCESS for cost savings
143+
log_class = "STANDARD"
144+
142145
# Enable to track the spot instance termination warning
143146
# instance_termination_watcher = {
144147
# enable = true

main.tf

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

141142
role_path = var.role_path
142143
role_permissions_boundary = var.role_permissions_boundary
@@ -228,6 +229,7 @@ module "runners" {
228229
tracing_config = var.tracing_config
229230
logging_retention_in_days = var.logging_retention_in_days
230231
logging_kms_key_id = var.logging_kms_key_id
232+
log_class = var.log_class
231233
enable_cloudwatch_agent = var.enable_cloudwatch_agent
232234
cloudwatch_config = var.cloudwatch_config
233235
runner_log_files = var.runner_log_files
@@ -307,6 +309,7 @@ module "runner_binaries" {
307309
tracing_config = var.tracing_config
308310
logging_retention_in_days = var.logging_retention_in_days
309311
logging_kms_key_id = var.logging_kms_key_id
312+
log_class = var.log_class
310313

311314
state_event_rule_binaries_syncer = var.state_event_rule_binaries_syncer
312315
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
@@ -349,6 +352,7 @@ module "ami_housekeeper" {
349352

350353
logging_retention_in_days = var.logging_retention_in_days
351354
logging_kms_key_id = var.logging_kms_key_id
355+
log_class = var.log_class
352356
log_level = var.log_level
353357

354358
role_path = var.role_path
@@ -370,6 +374,7 @@ locals {
370374
subnet_ids = var.lambda_subnet_ids
371375
lambda_tags = var.lambda_tags
372376
log_level = var.log_level
377+
log_class = var.log_class
373378
logging_kms_key_id = var.logging_kms_key_id
374379
logging_retention_in_days = var.logging_retention_in_days
375380
role_path = var.role_path

modules/ami-housekeeper/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ No modules.
115115
| <a name="input_lambda_tags"></a> [lambda\_tags](#input\_lambda\_tags) | Map of tags that will be added to all the lambda function resources. Note these are additional tags to the default tags. | `map(string)` | `{}` | no |
116116
| <a name="input_lambda_timeout"></a> [lambda\_timeout](#input\_lambda\_timeout) | Time out of the lambda in seconds. | `number` | `60` | no |
117117
| <a name="input_lambda_zip"></a> [lambda\_zip](#input\_lambda\_zip) | File location of the lambda zip file. | `string` | `null` | no |
118+
| <a name="input_log_class"></a> [log\_class](#input\_log\_class) | The log class of the CloudWatch log group. Valid values are `STANDARD` or `INFREQUENT_ACCESS`. | `string` | `"STANDARD"` | no |
118119
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'. | `string` | `"info"` | no |
119120
| <a name="input_logging_kms_key_id"></a> [logging\_kms\_key\_id](#input\_logging\_kms\_key\_id) | Specifies the kms key id to encrypt the logs with | `string` | `null` | no |
120121
| <a name="input_logging_retention_in_days"></a> [logging\_retention\_in\_days](#input\_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. | `number` | `180` | no |

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/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ No modules.
3939

4040
| Name | Description | Type | Default | Required |
4141
|------|-------------|------|---------|:--------:|
42-
| <a name="input_lambda"></a> [lambda](#input\_lambda) | Configuration for the lambda function.<br/><br/>`aws_partition`: Partition for the base arn if not 'aws'<br/>`architecture`: AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86\_64' functions.<br/>`environment_variables`: Environment variables for the lambda.<br/>`handler`: The entrypoint for the lambda.<br/>`principals`: Add extra principals to the role created for execution of the lambda, e.g. for local testing.<br/>`lambda_tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`log_level`: Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'.<br/>`logging_kms_key_id`: Specifies the kms key id to encrypt the logs with<br/>`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.<br/>`memory_size`: Memory size limit in MB of the lambda.<br/>`metrics_namespace`: Namespace for the metrics emitted by the lambda.<br/>`name`: The name of the lambda function.<br/>`prefix`: The prefix used for naming resources.<br/>`role_path`: The path that will be added to the role, if not set the environment name will be used.<br/>`role_permissions_boundary`: Permissions boundary that will be added to the created role for the lambda.<br/>`runtime`: AWS Lambda runtime.<br/>`s3_bucket`: S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly.<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/>`security_group_ids`: List of security group IDs associated with the Lambda function.<br/>`subnet_ids`: List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`.<br/>`tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`timeout`: Time out of the lambda in seconds.<br/>`tracing_config`: Configuration for lambda tracing.<br/>`zip`: File location of the lambda zip file. | <pre>object({<br/> aws_partition = optional(string, "aws")<br/> architecture = optional(string, "arm64")<br/> environment_variables = optional(map(string), {})<br/> handler = string<br/> lambda_tags = optional(map(string), {})<br/> log_level = optional(string, "info")<br/> logging_kms_key_id = optional(string, null)<br/> logging_retention_in_days = optional(number, 180)<br/> memory_size = optional(number, 256)<br/> metrics_namespace = optional(string, "GitHub Runners")<br/> name = string<br/> prefix = optional(string, null)<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })), [])<br/> role_path = optional(string, null)<br/> role_permissions_boundary = optional(string, null)<br/> runtime = optional(string, "nodejs24.x")<br/> s3_bucket = optional(string, null)<br/> s3_key = optional(string, null)<br/> s3_object_version = optional(string, null)<br/> security_group_ids = optional(list(string), [])<br/> subnet_ids = optional(list(string), [])<br/> tags = optional(map(string), {})<br/> timeout = optional(number, 60)<br/> tracing_config = optional(object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> }), {})<br/> zip = optional(string, null)<br/> })</pre> | n/a | yes |
42+
| <a name="input_lambda"></a> [lambda](#input\_lambda) | Configuration for the lambda function.<br/><br/>`aws_partition`: Partition for the base arn if not 'aws'<br/>`architecture`: AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86\_64' functions.<br/>`environment_variables`: Environment variables for the lambda.<br/>`handler`: The entrypoint for the lambda.<br/>`principals`: Add extra principals to the role created for execution of the lambda, e.g. for local testing.<br/>`lambda_tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`log_level`: Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'.<br/>`logging_kms_key_id`: Specifies the kms key id to encrypt the logs with<br/>`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.<br/>`log_class`: The log class of the CloudWatch log group. Valid values are `STANDARD` or `INFREQUENT_ACCESS`.<br/>`memory_size`: Memory size limit in MB of the lambda.<br/>`metrics_namespace`: Namespace for the metrics emitted by the lambda.<br/>`name`: The name of the lambda function.<br/>`prefix`: The prefix used for naming resources.<br/>`role_path`: The path that will be added to the role, if not set the environment name will be used.<br/>`role_permissions_boundary`: Permissions boundary that will be added to the created role for the lambda.<br/>`runtime`: AWS Lambda runtime.<br/>`s3_bucket`: S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly.<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/>`security_group_ids`: List of security group IDs associated with the Lambda function.<br/>`subnet_ids`: List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`.<br/>`tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`timeout`: Time out of the lambda in seconds.<br/>`tracing_config`: Configuration for lambda tracing.<br/>`zip`: File location of the lambda zip file. | <pre>object({<br/> aws_partition = optional(string, "aws")<br/> architecture = optional(string, "arm64")<br/> environment_variables = optional(map(string), {})<br/> handler = string<br/> lambda_tags = optional(map(string), {})<br/> log_level = optional(string, "info")<br/> log_class = optional(string, "STANDARD")<br/> logging_kms_key_id = optional(string, null)<br/> logging_retention_in_days = optional(number, 180)<br/> memory_size = optional(number, 256)<br/> metrics_namespace = optional(string, "GitHub Runners")<br/> name = string<br/> prefix = optional(string, null)<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })), [])<br/> role_path = optional(string, null)<br/> role_permissions_boundary = optional(string, null)<br/> runtime = optional(string, "nodejs24.x")<br/> s3_bucket = optional(string, null)<br/> s3_key = optional(string, null)<br/> s3_object_version = optional(string, null)<br/> security_group_ids = optional(list(string), [])<br/> subnet_ids = optional(list(string), [])<br/> tags = optional(map(string), {})<br/> timeout = optional(number, 60)<br/> tracing_config = optional(object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> }), {})<br/> zip = optional(string, null)<br/> })</pre> | n/a | yes |
4343

4444
## Outputs
4545

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)

0 commit comments

Comments
 (0)