Skip to content

Commit e34c7f2

Browse files
author
Damian Rekosz
committed
feat(runner-binaries-syncer): add s3_tags variable for additional S3 bucket tagging
1 parent 526f486 commit e34c7f2

7 files changed

Lines changed: 32 additions & 1 deletion

File tree

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ module "runner_binaries" {
308308

309309
state_event_rule_binaries_syncer = var.state_event_rule_binaries_syncer
310310
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
311+
s3_tags = var.runner_binaries_s3_tags
311312
s3_versioning = var.runner_binaries_s3_versioning
312313

313314
role_path = var.role_path

modules/multi-runner/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ locals {
1616
tmp_distinct_list_unique_os_and_arch = distinct([for i, config in local.runner_config : { "os_type" : config.runner_config.runner_os, "architecture" : config.runner_config.runner_architecture } if config.runner_config.enable_runner_binaries_syncer])
1717
unique_os_and_arch = { for i, v in local.tmp_distinct_list_unique_os_and_arch : "${v.os_type}_${v.architecture}" => v }
1818

19+
s3_tags = {
20+
for os_arch, tags_lists in {
21+
for i, config in local.runner_config :
22+
"${config.runner_config.runner_os}_${config.runner_config.runner_architecture}" => [config.runner_config.runner_binaries_s3_tags]...
23+
if config.runner_config.enable_runner_binaries_syncer
24+
} :
25+
os_arch => merge(var.runner_binaries_s3_tags, merge(flatten(tags_lists)...))
26+
}
27+
1928
ssm_root_path = "/${var.ssm_paths.root}/${var.prefix}"
2029
}
2130

modules/multi-runner/runner-binaries.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module "runner_binaries" {
2525
state_event_rule_binaries_syncer = var.state_event_rule_binaries_syncer
2626

2727
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
28+
s3_tags = local.s3_tags[each.key]
2829
s3_versioning = var.runner_binaries_s3_versioning
2930

3031
role_path = var.role_path

modules/multi-runner/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ variable "multi_runner_config" {
114114
cloudwatch_config = optional(string, null)
115115
userdata_pre_install = optional(string, "")
116116
userdata_post_install = optional(string, "")
117+
runner_binaries_s3_tags = optional(map(string), {})
117118
runner_hook_job_started = optional(string, "")
118119
runner_hook_job_completed = optional(string, "")
119120
runner_ec2_tags = optional(map(string), {})
@@ -222,6 +223,7 @@ variable "multi_runner_config" {
222223
cloudwatch_config: "(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."
223224
userdata_pre_install: "Script to be ran before the GitHub Actions runner is installed on the EC2 instances"
224225
userdata_post_install: "Script to be ran after the GitHub Actions runner is installed on the EC2 instances"
226+
runner_binaries_s3_tags: "Map of tags that will be added to the S3 bucket used by the runner binaries syncer for this runner configuration. Note these are additional tags to the default tags."
225227
runner_hook_job_started: "Script to be ran in the runner environment at the beginning of every job"
226228
runner_hook_job_completed: "Script to be ran in the runner environment at the end of every job"
227229
runner_ec2_tags: "Map of tags that will be added to the launch template instance tag specifications."
@@ -404,6 +406,12 @@ variable "runner_binaries_s3_sse_configuration" {
404406
}
405407
}
406408

409+
variable "runner_binaries_s3_tags" {
410+
description = "Map of tags that will be added to the S3 bucket. Note these are additional tags to the default tags."
411+
type = map(string)
412+
default = {}
413+
}
414+
407415
variable "runner_binaries_s3_versioning" {
408416
description = "Status of S3 versioning for runner-binaries S3 bucket. Once set to Enabled the change cannot be reverted via Terraform!"
409417
type = string

modules/runner-binaries-syncer/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ locals {
55
resource "aws_s3_bucket" "action_dist" {
66
bucket = var.distribution_bucket_name
77
force_destroy = true
8-
tags = var.tags
8+
tags = merge(var.tags, var.s3_tags)
99
}
1010

1111
resource "aws_s3_bucket_ownership_controls" "this" {

modules/runner-binaries-syncer/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ variable "s3_logging_bucket_prefix" {
4545
}
4646
}
4747

48+
variable "s3_tags" {
49+
description = "Map of tags that will be added to the S3 bucket. Note these are additional tags to the default tags."
50+
type = map(string)
51+
default = {}
52+
}
53+
4854
variable "state_event_rule_binaries_syncer" {
4955
type = string
5056
description = "Option to disable EventBridge Lambda trigger for the binary syncer, useful to stop automatic updates of binary distribution"

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ variable "runner_binaries_s3_sse_configuration" {
192192
}
193193
}
194194

195+
variable "runner_binaries_s3_tags" {
196+
description = "Map of tags that will be added to the S3 bucket. Note these are additional tags to the default tags."
197+
type = map(string)
198+
default = {}
199+
}
200+
195201
variable "runner_binaries_s3_versioning" {
196202
description = "Status of S3 versioning for runner-binaries S3 bucket. Once set to Enabled the change cannot be reverted via Terraform!"
197203
type = string

0 commit comments

Comments
 (0)