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

Commit ae84302

Browse files
authored
feat: add option to specify SSE config for dist bucket (#1324)
* feat: dist bucket SSE config * fixup! feat: dist bucket SSE config
1 parent 922ef99 commit ae84302

File tree

7 files changed

+154
-101
lines changed

7 files changed

+154
-101
lines changed

Diff for: README.md

+83-80
Large diffs are not rendered by default.

Diff for: examples/default/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ module "runners" {
3939
# enable access to the runners via SSM
4040
enable_ssm_on_runners = true
4141

42+
# use S3 or KMS SSE to runners S3 bucket
43+
# runner_binaries_s3_sse_configuration = {
44+
# rule = {
45+
# apply_server_side_encryption_by_default = {
46+
# sse_algorithm = "AES256"
47+
# }
48+
# }
49+
# }
50+
4251
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
4352
# idle_config = [{
4453
# cron = "* * 9-17 * * *"

Diff for: main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ module "runner_binaries" {
160160
lambda_timeout = var.runner_binaries_syncer_lambda_timeout
161161
logging_retention_in_days = var.logging_retention_in_days
162162

163+
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
164+
163165
role_path = var.role_path
164166
role_permissions_boundary = var.role_permissions_boundary
165167

Diff for: modules/runner-binaries-syncer/README.md

+20-19
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,26 @@ No modules.
7575

7676
| Name | Description | Type | Default | Required |
7777
|------|-------------|------|---------|:--------:|
78-
| aws\_region | AWS region. | `string` | n/a | yes |
79-
| distribution\_bucket\_name | Bucket for storing the action runner distribution. | `string` | n/a | yes |
80-
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
81-
| lambda\_s3\_bucket | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
82-
| lambda\_schedule\_expression | Scheduler expression for action runner binary syncer. | `string` | `"cron(27 * * * ? *)"` | no |
83-
| lambda\_security\_group\_ids | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no |
84-
| 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 |
85-
| lambda\_timeout | Time out of the lambda in seconds. | `number` | `300` | no |
86-
| lambda\_zip | File location of the lambda zip file. | `string` | `null` | no |
87-
| log\_level | Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'. | `string` | `"info"` | no |
88-
| log\_type | Logging format for lambda logging. Valid values are 'json', 'pretty', 'hidden'. | `string` | `"pretty"` | no |
89-
| 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` | `7` | no |
90-
| role\_path | The path that will be added to the role, if not set the environment name will be used. | `string` | `null` | no |
91-
| role\_permissions\_boundary | Permissions boundary that will be added to the created role for the lambda. | `string` | `null` | no |
92-
| runner\_allow\_prerelease\_binaries | Allow the runners to update to prerelease binaries. | `bool` | `false` | no |
93-
| runner\_architecture | The platform architecture for the runner instance (x64, arm64), defaults to 'x64' | `string` | `"x64"` | no |
94-
| syncer\_lambda\_s3\_key | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
95-
| syncer\_lambda\_s3\_object\_version | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
96-
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
78+
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes |
79+
| <a name="input_distribution_bucket_name"></a> [distribution\_bucket\_name](#input\_distribution\_bucket\_name) | Bucket for storing the action runner distribution. | `string` | n/a | yes |
80+
| <a name="input_environment"></a> [environment](#input\_environment) | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
81+
| <a name="input_lambda_s3_bucket"></a> [lambda\_s3\_bucket](#input\_lambda\_s3\_bucket) | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
82+
| <a name="input_lambda_schedule_expression"></a> [lambda\_schedule\_expression](#input\_lambda\_schedule\_expression) | Scheduler expression for action runner binary syncer. | `string` | `"cron(27 * * * ? *)"` | no |
83+
| <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 |
84+
| <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 |
85+
| <a name="input_lambda_timeout"></a> [lambda\_timeout](#input\_lambda\_timeout) | Time out of the lambda in seconds. | `number` | `300` | no |
86+
| <a name="input_lambda_zip"></a> [lambda\_zip](#input\_lambda\_zip) | File location of the lambda zip file. | `string` | `null` | no |
87+
| <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 |
88+
| <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 |
89+
| <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` | `7` | no |
90+
| <a name="input_role_path"></a> [role\_path](#input\_role\_path) | The path that will be added to the role, if not set the environment name will be used. | `string` | `null` | no |
91+
| <a name="input_role_permissions_boundary"></a> [role\_permissions\_boundary](#input\_role\_permissions\_boundary) | Permissions boundary that will be added to the created role for the lambda. | `string` | `null` | no |
92+
| <a name="input_runner_allow_prerelease_binaries"></a> [runner\_allow\_prerelease\_binaries](#input\_runner\_allow\_prerelease\_binaries) | Allow the runners to update to prerelease binaries. | `bool` | `false` | no |
93+
| <a name="input_runner_architecture"></a> [runner\_architecture](#input\_runner\_architecture) | The platform architecture for the runner instance (x64, arm64), defaults to 'x64' | `string` | `"x64"` | no |
94+
| <a name="input_server_side_encryption_configuration"></a> [server\_side\_encryption\_configuration](#input\_server\_side\_encryption\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |
95+
| <a name="input_syncer_lambda_s3_key"></a> [syncer\_lambda\_s3\_key](#input\_syncer\_lambda\_s3\_key) | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
96+
| <a name="input_syncer_lambda_s3_object_version"></a> [syncer\_lambda\_s3\_object\_version](#input\_syncer\_lambda\_s3\_object\_version) | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
97+
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
9798

9899
## Outputs
99100

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

+26
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,32 @@ resource "aws_s3_bucket" "action_dist" {
88
force_destroy = true
99
tags = var.tags
1010

11+
# Max 1 block - server_side_encryption_configuration
12+
dynamic "server_side_encryption_configuration" {
13+
for_each = length(keys(var.server_side_encryption_configuration)) == 0 ? [] : [var.server_side_encryption_configuration]
14+
15+
content {
16+
17+
dynamic "rule" {
18+
for_each = length(keys(lookup(server_side_encryption_configuration.value, "rule", {}))) == 0 ? [] : [lookup(server_side_encryption_configuration.value, "rule", {})]
19+
20+
content {
21+
bucket_key_enabled = lookup(rule.value, "bucket_key_enabled", null)
22+
23+
dynamic "apply_server_side_encryption_by_default" {
24+
for_each = length(keys(lookup(rule.value, "apply_server_side_encryption_by_default", {}))) == 0 ? [] : [
25+
lookup(rule.value, "apply_server_side_encryption_by_default", {})]
26+
27+
content {
28+
sse_algorithm = apply_server_side_encryption_by_default.value.sse_algorithm
29+
kms_master_key_id = lookup(apply_server_side_encryption_by_default.value, "kms_master_key_id", null)
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
1137
lifecycle_rule {
1238
enabled = true
1339
abort_incomplete_multipart_upload_days = 7

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ variable "environment" {
1717
variable "distribution_bucket_name" {
1818
description = "Bucket for storing the action runner distribution."
1919
type = string
20-
20+
2121
# Make sure the bucket name only contains legal characters
2222
validation {
2323
error_message = "Only lowercase alphanumeric characters and hyphens allowed in the bucket name."
24-
condition = can(regex("^[a-z0-9-]*$", var.distribution_bucket_name))
24+
condition = can(regex("^[a-z0-9-]*$", var.distribution_bucket_name))
2525
}
2626
}
2727
variable "lambda_schedule_expression" {
@@ -130,3 +130,9 @@ variable "log_level" {
130130
error_message = "`log_level` value not valid. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'."
131131
}
132132
}
133+
134+
variable "server_side_encryption_configuration" {
135+
description = "Map containing server-side encryption configuration."
136+
type = any
137+
default = {}
138+
}

Diff for: variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ variable "runner_binaries_syncer_lambda_timeout" {
111111
default = 300
112112
}
113113

114+
variable "runner_binaries_s3_sse_configuration" {
115+
description = "Map containing server-side encryption configuration for runner-binaries S3 bucket."
116+
type = any
117+
default = {}
118+
}
119+
114120
variable "role_permissions_boundary" {
115121
description = "Permissions boundary that will be added to the created roles."
116122
type = string

0 commit comments

Comments
 (0)