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

Commit 3f1a67f

Browse files
authored
feat: Add option for KMS encryption for cloudwatch log groups (#1833)
* feat: added kms encryption to cloudwatch log groups * chore: added documentation for log kms encryption
1 parent c5a6501 commit 3f1a67f

14 files changed

+36
-0
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ In case the setup does not work as intended follow the trace of events:
430430
| <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 |
431431
| <a name="input_log_type"></a> [log\_type](#input\_log\_type) | Logging format for lambda logging. Valid values are 'json', 'pretty', 'hidden'. | `string` | `"pretty"` | no |
432432
| <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 |
433+
| <a name="input_logging_kms_key_id"></a> [logging\_retention\_in\_days](#input\_kms\_key\_id) | Specifies the kms key id to encrypt the cloudwatch logs with. | `string` | `null` | no |
433434
| <a name="input_market_options"></a> [market\_options](#input\_market\_options) | DEPCRECATED: Replaced by `instance_target_capacity_type`. | `string` | `null` | no |
434435
| <a name="input_minimum_running_time_in_minutes"></a> [minimum\_running\_time\_in\_minutes](#input\_minimum\_running\_time\_in\_minutes) | The time an ec2 action runner should be running at minimum before terminated if not busy. | `number` | `null` | no |
435436
| <a name="input_pool_config"></a> [pool\_config](#input\_pool\_config) | The configuration for updating the pool. The `pool_size` to adjust to by the events triggered by the the `schedule_expression. For example you can configure a cron expression for week days to adjust the pool to 10 and another expression for the weekend to adjust the pool to 1.` | <pre>list(object({<br> schedule_expression = string<br> size = number<br> }))</pre> | `[]` | no |

Diff for: main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module "webhook" {
6767
lambda_zip = var.webhook_lambda_zip
6868
lambda_timeout = var.webhook_lambda_timeout
6969
logging_retention_in_days = var.logging_retention_in_days
70+
logging_kms_key_id = var.logging_kms_key_id
7071

7172
# labels
7273
enable_workflow_job_labels_check = var.runner_enable_workflow_job_labels_check
@@ -133,6 +134,7 @@ module "runners" {
133134
lambda_subnet_ids = var.lambda_subnet_ids
134135
lambda_security_group_ids = var.lambda_security_group_ids
135136
logging_retention_in_days = var.logging_retention_in_days
137+
logging_kms_key_id = var.logging_kms_key_id
136138
enable_cloudwatch_agent = var.enable_cloudwatch_agent
137139
cloudwatch_config = var.cloudwatch_config
138140
runner_log_files = var.runner_log_files
@@ -188,6 +190,7 @@ module "runner_binaries" {
188190
lambda_zip = var.runner_binaries_syncer_lambda_zip
189191
lambda_timeout = var.runner_binaries_syncer_lambda_timeout
190192
logging_retention_in_days = var.logging_retention_in_days
193+
logging_kms_key_id = var.logging_kms_key_id
191194

192195
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
193196

Diff for: modules/runner-binaries-syncer/runner-binaries-syncer.tf

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ resource "aws_lambda_function" "syncer" {
4545
resource "aws_cloudwatch_log_group" "syncer" {
4646
name = "/aws/lambda/${aws_lambda_function.syncer.function_name}"
4747
retention_in_days = var.logging_retention_in_days
48+
kms_key_id = var.logging_kms_key_id
4849
tags = var.tags
4950
}
5051

Diff for: modules/runner-binaries-syncer/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ variable "logging_retention_in_days" {
8484
default = 7
8585
}
8686

87+
variable "logging_kms_key_id" {
88+
description = "Specifies the kms key id to encrypt the logs with"
89+
type = string
90+
default = null
91+
}
92+
8793
variable "runner_allow_prerelease_binaries" {
8894
description = "Allow the runners to update to prerelease binaries."
8995
type = bool

Diff for: modules/runners/logging.tf

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ resource "aws_cloudwatch_log_group" "gh_runners" {
5454
count = length(local.loggroups_names)
5555
name = local.loggroups_names[count.index]
5656
retention_in_days = var.logging_retention_in_days
57+
kms_key_id = var.logging_kms_key_id
5758
tags = local.tags
5859
}
5960

Diff for: modules/runners/pool.tf

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module "pool" {
1919
log_level = var.log_level
2020
log_type = var.log_type
2121
logging_retention_in_days = var.logging_retention_in_days
22+
logging_kms_key_id = var.logging_retention_in_days
2223
reserved_concurrent_executions = var.pool_lambda_reserved_concurrent_executions
2324
s3_bucket = var.lambda_s3_bucket
2425
s3_key = var.runners_lambda_s3_key

Diff for: modules/runners/pool/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ resource "aws_lambda_function" "pool" {
4949
resource "aws_cloudwatch_log_group" "pool" {
5050
name = "/aws/lambda/${aws_lambda_function.pool.function_name}"
5151
retention_in_days = var.config.lambda.logging_retention_in_days
52+
kms_key_id = var.config.lambda.logging_kms_key_id
5253
tags = var.config.tags
5354
}
5455

Diff for: modules/runners/pool/variables.tf

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ variable "config" {
44
log_level = string
55
log_type = string
66
logging_retention_in_days = number
7+
logging_kms_key_id = string
78
reserved_concurrent_executions = number
89
s3_bucket = string
910
s3_key = string

Diff for: modules/runners/scale-down.tf

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ resource "aws_lambda_function" "scale_down" {
4646
resource "aws_cloudwatch_log_group" "scale_down" {
4747
name = "/aws/lambda/${aws_lambda_function.scale_down.function_name}"
4848
retention_in_days = var.logging_retention_in_days
49+
kms_key_id = var.logging_kms_key_id
4950
tags = var.tags
5051
}
5152

Diff for: modules/runners/scale-up.tf

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ resource "aws_lambda_function" "scale_up" {
4949
resource "aws_cloudwatch_log_group" "scale_up" {
5050
name = "/aws/lambda/${aws_lambda_function.scale_up.function_name}"
5151
retention_in_days = var.logging_retention_in_days
52+
kms_key_id = var.logging_kms_key_id
5253
tags = var.tags
5354
}
5455

Diff for: modules/runners/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ variable "logging_retention_in_days" {
280280
default = 180
281281
}
282282

283+
variable "logging_kms_key_id" {
284+
description = "Specifies the kms key id to encrypt the logs with"
285+
type = string
286+
default = null
287+
}
288+
283289
variable "enable_ssm_on_runners" {
284290
description = "Enable to allow access to the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances."
285291
type = bool

Diff for: modules/webhook/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ variable "logging_retention_in_days" {
5656
default = 7
5757
}
5858

59+
variable "logging_kms_key_id" {
60+
description = "Specifies the kms key id to encrypt the logs with"
61+
type = string
62+
default = null
63+
}
64+
5965
variable "lambda_s3_bucket" {
6066
description = "S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly."
6167
default = null

Diff for: modules/webhook/webhook.tf

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ resource "aws_lambda_function" "webhook" {
2929
resource "aws_cloudwatch_log_group" "webhook" {
3030
name = "/aws/lambda/${aws_lambda_function.webhook.function_name}"
3131
retention_in_days = var.logging_retention_in_days
32+
kms_key_id = var.logging_kms_key_id
3233
tags = var.tags
3334
}
3435

Diff for: variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ variable "logging_retention_in_days" {
211211
default = 180
212212
}
213213

214+
variable "logging_kms_key_id" {
215+
description = "Specifies the kms key id to encrypt the logs with"
216+
type = string
217+
default = null
218+
}
219+
214220
variable "runner_allow_prerelease_binaries" {
215221
description = "Allow the runners to update to prerelease binaries."
216222
type = bool

0 commit comments

Comments
 (0)