Skip to content

Commit e679021

Browse files
reedlodennpalmGuptaNavdeep1983github-actions[bot]
authored
feat(syncer): Enable S3 bucket versioning for syncer S3 bucket (github-aws-runners#3108)
* feat(syncer): Support configuring S3 bucket versioning for syncer S3 bucket Many compliance obligations require S3 bucket versioning be enabled in order to meet specific integrity and availability controls. Add support for setting the status of such versioning, with the default being that it is disabled. * Apply suggestions from code review Co-authored-by: Niek Palm <[email protected]> * docs: auto update terraform docs --------- Co-authored-by: Niek Palm <[email protected]> Co-authored-by: GuptaNavdeep1983 <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 22cf291 commit e679021

File tree

11 files changed

+42
-4
lines changed

11 files changed

+42
-4
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ We welcome any improvement to the standard module to make the default as secure
556556
| <a name="input_runner_binaries_s3_logging_bucket"></a> [runner\_binaries\_s3\_logging\_bucket](#input\_runner\_binaries\_s3\_logging\_bucket) | Bucket for action runner distribution bucket access logging. | `string` | `null` | no |
557557
| <a name="input_runner_binaries_s3_logging_bucket_prefix"></a> [runner\_binaries\_s3\_logging\_bucket\_prefix](#input\_runner\_binaries\_s3\_logging\_bucket\_prefix) | Bucket prefix for action runner distribution bucket access logging. | `string` | `null` | no |
558558
| <a name="input_runner_binaries_s3_sse_configuration"></a> [runner\_binaries\_s3\_sse\_configuration](#input\_runner\_binaries\_s3\_sse\_configuration) | Map containing server-side encryption configuration for runner-binaries S3 bucket. | `any` | <pre>{<br> "rule": {<br> "apply_server_side_encryption_by_default": {<br> "sse_algorithm": "AES256"<br> }<br> }<br>}</pre> | no |
559+
| <a name="input_runner_binaries_s3_versioning"></a> [runner\_binaries\_s3\_versioning](#input\_runner\_binaries\_s3\_versioning) | Status of S3 versioning for runner-binaries S3 bucket. Once set to Enabled the change cannot be reverted via Terraform! | `string` | `"Disabled"` | no |
559560
| <a name="input_runner_binaries_syncer_lambda_timeout"></a> [runner\_binaries\_syncer\_lambda\_timeout](#input\_runner\_binaries\_syncer\_lambda\_timeout) | Time out of the binaries sync lambda in seconds. | `number` | `300` | no |
560561
| <a name="input_runner_binaries_syncer_lambda_zip"></a> [runner\_binaries\_syncer\_lambda\_zip](#input\_runner\_binaries\_syncer\_lambda\_zip) | File location of the binaries sync lambda zip file. | `string` | `null` | no |
561562
| <a name="input_runner_boot_time_in_minutes"></a> [runner\_boot\_time\_in\_minutes](#input\_runner\_boot\_time\_in\_minutes) | The minimum time for an EC2 runner to boot and register as a runner. | `number` | `5` | no |
@@ -605,6 +606,7 @@ We welcome any improvement to the standard module to make the default as secure
605606
| <a name="output_webhook"></a> [webhook](#output\_webhook) | n/a |
606607
<!-- END_TF_DOCS -->
607608

609+
608610
## Contribution
609611

610612
We welcome contribution, please checkout the [contribution guide](CONTRIBUTING.md). Be-aware we use [pre commit hooks](https://pre-commit.com/) to update the docs.

examples/arm64/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ module "runners" {
5151
# }
5252
# }
5353

54+
# enable S3 versioning for runners S3 bucket
55+
# runner_binaries_s3_versioning = "Enabled"
56+
5457
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
5558
# idle_config = [{
5659
# cron = "* * 9-17 * * *"

examples/default/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ module "runners" {
6262
# }
6363
# }
6464

65+
# enable S3 versioning for runners S3 bucket
66+
# runner_binaries_s3_versioning = "Enabled"
67+
6568
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
6669
# idle_config = [{
6770
# cron = "* * 9-17 * * *"

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ module "runner_binaries" {
305305

306306
enable_event_rule_binaries_syncer = var.enable_event_rule_binaries_syncer
307307
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
308+
s3_versioning = var.runner_binaries_s3_versioning
308309

309310
role_path = var.role_path
310311
role_permissions_boundary = var.role_permissions_boundary

modules/multi-runner/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ module "multi-runner" {
149149
| <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 |
150150
| <a name="input_runner_additional_security_group_ids"></a> [runner\_additional\_security\_group\_ids](#input\_runner\_additional\_security\_group\_ids) | (optional) List of additional security groups IDs to apply to the runner | `list(string)` | `[]` | no |
151151
| <a name="input_runner_binaries_s3_sse_configuration"></a> [runner\_binaries\_s3\_sse\_configuration](#input\_runner\_binaries\_s3\_sse\_configuration) | Map containing server-side encryption configuration for runner-binaries S3 bucket. | `any` | `{}` | no |
152+
| <a name="input_runner_binaries_s3_versioning"></a> [runner\_binaries\_s3\_versioning](#input\_runner\_binaries\_s3\_versioning) | Status of S3 versioning for runner-binaries S3 bucket. Once set to Enabled the change cannot be reverted via Terraform! | `string` | `"Disabled"` | no |
152153
| <a name="input_runner_binaries_syncer_lambda_timeout"></a> [runner\_binaries\_syncer\_lambda\_timeout](#input\_runner\_binaries\_syncer\_lambda\_timeout) | Time out of the binaries sync lambda in seconds. | `number` | `300` | no |
153154
| <a name="input_runner_binaries_syncer_lambda_zip"></a> [runner\_binaries\_syncer\_lambda\_zip](#input\_runner\_binaries\_syncer\_lambda\_zip) | File location of the binaries sync lambda zip file. | `string` | `null` | no |
154155
| <a name="input_runner_egress_rules"></a> [runner\_egress\_rules](#input\_runner\_egress\_rules) | List of egress rules for the GitHub runner instances. | <pre>list(object({<br> cidr_blocks = list(string)<br> ipv6_cidr_blocks = list(string)<br> prefix_list_ids = list(string)<br> from_port = number<br> protocol = string<br> security_groups = list(string)<br> self = bool<br> to_port = number<br> description = string<br> }))</pre> | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": null,<br> "from_port": 0,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "prefix_list_ids": null,<br> "protocol": "-1",<br> "security_groups": null,<br> "self": null,<br> "to_port": 0<br> }<br>]</pre> | no |
@@ -178,4 +179,4 @@ module "multi-runner" {
178179
| <a name="output_runners"></a> [runners](#output\_runners) | n/a |
179180
| <a name="output_ssm_parameters"></a> [ssm\_parameters](#output\_ssm\_parameters) | n/a |
180181
| <a name="output_webhook"></a> [webhook](#output\_webhook) | n/a |
181-
<!-- END_TF_DOCS -->
182+
<!-- END_TF_DOCS -->

modules/multi-runner/runner-binaries.tf

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module "runner_binaries" {
2323
enable_event_rule_binaries_syncer = var.enable_event_rule_binaries_syncer
2424

2525
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
26+
s3_versioning = var.runner_binaries_s3_versioning
2627

2728
role_path = var.role_path
2829
role_permissions_boundary = var.role_permissions_boundary

modules/multi-runner/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ variable "runner_binaries_s3_sse_configuration" {
324324
default = {}
325325
}
326326

327+
variable "runner_binaries_s3_versioning" {
328+
description = "Status of S3 versioning for runner-binaries S3 bucket. Once set to Enabled the change cannot be reverted via Terraform!"
329+
type = string
330+
default = "Disabled"
331+
}
332+
327333
variable "runner_binaries_syncer_lambda_timeout" {
328334
description = "Time out of the binaries sync lambda in seconds."
329335
type = number

modules/runner-binaries-syncer/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ No modules.
7878
| [aws_s3_bucket_policy.action_dist_sse_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
7979
| [aws_s3_bucket_public_access_block.action_dist](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
8080
| [aws_s3_bucket_server_side_encryption_configuration.action_dist](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
81+
| [aws_s3_bucket_versioning.action_dist](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_versioning) | resource |
8182
| [aws_s3_object.trigger](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_object) | resource |
8283
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
8384
| [aws_iam_policy_document.action_dist_sse_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
@@ -114,7 +115,8 @@ No modules.
114115
| <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 |
115116
| <a name="input_s3_logging_bucket"></a> [s3\_logging\_bucket](#input\_s3\_logging\_bucket) | Bucket for action runner distribution bucket access logging. | `string` | `null` | no |
116117
| <a name="input_s3_logging_bucket_prefix"></a> [s3\_logging\_bucket\_prefix](#input\_s3\_logging\_bucket\_prefix) | Bucket prefix for action runner distribution bucket access logging. | `string` | `null` | no |
117-
| <a name="input_server_side_encryption_configuration"></a> [server\_side\_encryption\_configuration](#input\_server\_side\_encryption\_configuration) | Map containing server-side encryption configuration. | `any` | <pre>{<br> "rule": {<br> "apply_server_side_encryption_by_default": {<br> "sse_algorithm": "AES256"<br> }<br> }<br>}</pre> | no |
118+
| <a name="input_s3_versioning"></a> [s3\_versioning](#input\_s3\_versioning) | Status of S3 versioning for runner-binaries S3 bucket. | `string` | `"Disabled"` | no |
119+
| <a name="input_server_side_encryption_configuration"></a> [server\_side\_encryption\_configuration](#input\_server\_side\_encryption\_configuration) | Map containing server-side encryption configuration for runner-binaries S3 bucket. | `any` | <pre>{<br> "rule": {<br> "apply_server_side_encryption_by_default": {<br> "sse_algorithm": "AES256"<br> }<br> }<br>}</pre> | no |
118120
| <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. | `string` | `null` | no |
119121
| <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. | `string` | `null` | no |
120122
| <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 |
@@ -128,4 +130,4 @@ No modules.
128130
| <a name="output_lambda_log_group"></a> [lambda\_log\_group](#output\_lambda\_log\_group) | n/a |
129131
| <a name="output_lambda_role"></a> [lambda\_role](#output\_lambda\_role) | n/a |
130132
| <a name="output_runner_distribution_object_key"></a> [runner\_distribution\_object\_key](#output\_runner\_distribution\_object\_key) | n/a |
131-
<!-- END_TF_DOCS -->
133+
<!-- END_TF_DOCS -->

modules/runner-binaries-syncer/main.tf

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ resource "aws_s3_bucket_logging" "action_dist_logging" {
7272
target_prefix = var.s3_logging_bucket_prefix != null ? var.s3_logging_bucket_prefix : var.distribution_bucket_name
7373
}
7474

75+
resource "aws_s3_bucket_versioning" "action_dist" {
76+
bucket = aws_s3_bucket.action_dist.id
77+
versioning_configuration {
78+
status = var.s3_versioning
79+
}
80+
}
81+
7582
data "aws_iam_policy_document" "action_dist_sse_policy" {
7683
count = try(var.server_side_encryption_configuration.rule.apply_server_side_encryption_by_default, null) != null ? 1 : 0
7784

modules/runner-binaries-syncer/variables.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ variable "log_level" {
206206
}
207207

208208
variable "server_side_encryption_configuration" {
209-
description = "Map containing server-side encryption configuration."
209+
description = "Map containing server-side encryption configuration for runner-binaries S3 bucket."
210210
type = any
211211
default = {
212212
rule = {
@@ -217,6 +217,12 @@ variable "server_side_encryption_configuration" {
217217
}
218218
}
219219

220+
variable "s3_versioning" {
221+
description = "Status of S3 versioning for runner-binaries S3 bucket."
222+
type = string
223+
default = "Disabled"
224+
}
225+
220226
variable "lambda_principals" {
221227
description = "(Optional) add extra principals to the role created for execution of the lambda, e.g. for local testing."
222228
type = list(object({

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ variable "runner_binaries_s3_sse_configuration" {
141141
}
142142
}
143143

144+
variable "runner_binaries_s3_versioning" {
145+
description = "Status of S3 versioning for runner-binaries S3 bucket. Once set to Enabled the change cannot be reverted via Terraform!"
146+
type = string
147+
default = "Disabled"
148+
}
149+
144150
variable "runner_binaries_s3_logging_bucket" {
145151
description = "Bucket for action runner distribution bucket access logging."
146152
type = string

0 commit comments

Comments
 (0)