Skip to content

Commit 47f4076

Browse files
committed
feat(runners): add ec2_custom_allowed_tags variable and update create_tag policy to support custom tags
1 parent bbf1bd8 commit 47f4076

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

modules/runners/policies-runner.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ resource "aws_iam_role_policy" "describe_tags" {
6060
resource "aws_iam_role_policy" "create_tag" {
6161
name = "runner-create-tags"
6262
role = aws_iam_role.runner.name
63-
policy = templatefile("${path.module}/policies/instance-create-tags-policy.json", {})
63+
policy = templatefile("${path.module}/policies/instance-create-tags-policy.json", {
64+
ec2_custom_allowed_tags = var.ec2_custom_allowed_tags
65+
})
6466
}
6567

6668
resource "aws_iam_role_policy_attachment" "managed_policies" {

modules/runners/policies/instance-create-tags-policy.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"Action": "ec2:CreateTags",
66
"Condition": {
77
"ForAllValues:StringEquals": {
8-
"aws:TagKeys": [
9-
"ghr:github_runner_id"
10-
]
8+
"aws:TagKeys": ${jsonencode(concat(["ghr:github_runner_id"], ec2_custom_allowed_tags))}
119
},
1210
"StringEquals": {
1311
"aws:ARN": "$${ec2:SourceInstanceARN}"

modules/runners/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,3 +761,9 @@ variable "user_agent" {
761761
type = string
762762
default = null
763763
}
764+
765+
variable "ec2_custom_allowed_tags" {
766+
description = "Allows the EC2 instance to create tags listed here."
767+
type = list(string)
768+
default = []
769+
}

0 commit comments

Comments
 (0)