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

Commit f37df23

Browse files
authored
fix: configurable metadata options for runners (#1377)
1 parent 0a910e0 commit f37df23

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ In case the setup does not work as intended follow the trace of events:
411411
| <a name="input_runner_group_name"></a> [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no |
412412
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |
413413
| <a name="input_runner_log_files"></a> [runner\_log\_files](#input\_runner\_log\_files) | (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. | <pre>list(object({<br> log_group_name = string<br> prefix_log_group = bool<br> file_path = string<br> log_stream_name = string<br> }))</pre> | <pre>[<br> {<br> "file_path": "/var/log/messages",<br> "log_group_name": "messages",<br> "log_stream_name": "{instance_id}",<br> "prefix_log_group": true<br> },<br> {<br> "file_path": "/var/log/user-data.log",<br> "log_group_name": "user_data",<br> "log_stream_name": "{instance_id}",<br> "prefix_log_group": true<br> },<br> {<br> "file_path": "/home/ec2-user/actions-runner/_diag/Runner_**.log",<br> "log_group_name": "runner",<br> "log_stream_name": "{instance_id}",<br> "prefix_log_group": true<br> }<br>]</pre> | no |
414+
| <a name="input_runner_metadata_options"></a> [runner\_metadata\_options](#input\_runner\_metadata\_options) | Metadata options for the ec2 runner instances. | `map(any)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 1,<br> "http_tokens": "optional"<br>}</pre> | no |
414415
| <a name="input_runners_lambda_s3_key"></a> [runners\_lambda\_s3\_key](#input\_runners\_lambda\_s3\_key) | S3 key for runners lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
415416
| <a name="input_runners_lambda_s3_object_version"></a> [runners\_lambda\_s3\_object\_version](#input\_runners\_lambda\_s3\_object\_version) | S3 object version for runners lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
416417
| <a name="input_runners_lambda_zip"></a> [runners\_lambda\_zip](#input\_runners\_lambda\_zip) | File location of the lambda zip file for scaling runners. | `string` | `null` | no |

Diff for: main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ module "runners" {
103103
egress_rules = var.runner_egress_rules
104104
runner_additional_security_group_ids = var.runner_additional_security_group_ids
105105
volume_size = var.volume_size
106+
metadata_options = var.runner_metadata_options
106107

107108
lambda_s3_bucket = var.lambda_s3_bucket
108109
runners_lambda_s3_key = var.runners_lambda_s3_key

Diff for: modules/runners/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ No modules.
136136
| <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 |
137137
| <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 |
138138
| <a name="input_market_options"></a> [market\_options](#input\_market\_options) | Market options for the action runner instances. | `string` | `"spot"` | no |
139+
| <a name="input_metadata_options"></a> [metadata\_options](#input\_metadata\_options) | Metadata options for the ec2 runner instances. | `map(any)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 1,<br> "http_tokens": "optional"<br>}</pre> | no |
139140
| <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 non busy. | `number` | `5` | no |
140141
| <a name="input_overrides"></a> [overrides](#input\_overrides) | This map provides the possibility to override some defaults. The following attributes are supported: `name_sg` overrides the `Name` tag for all security groups created by this module. `name_runner_agent_instance` overrides the `Name` tag for the ec2 instance defined in the auto launch configuration. `name_docker_machine_runners` overrides the `Name` tag spot instances created by the runner agent. | `map(string)` | <pre>{<br> "name_runner": "",<br> "name_sg": ""<br>}</pre> | no |
141142
| <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 |
@@ -144,6 +145,7 @@ No modules.
144145
| <a name="input_runner_architecture"></a> [runner\_architecture](#input\_runner\_architecture) | The platform architecture of the runner instance\_type. | `string` | `"x64"` | no |
145146
| <a name="input_runner_as_root"></a> [runner\_as\_root](#input\_runner\_as\_root) | Run the action runner under the root user. | `bool` | `false` | no |
146147
| <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 |
148+
| <a name="input_runner_ec2_tags"></a> [runner\_ec2\_tags](#input\_runner\_ec2\_tags) | Map of tags that will be added to the launch template instance tag specificatons. | `map(string)` | `{}` | no |
147149
| <a name="input_runner_extra_labels"></a> [runner\_extra\_labels](#input\_runner\_extra\_labels) | Extra labels for the runners (GitHub). Separate each label by a comma | `string` | `""` | no |
148150
| <a name="input_runner_group_name"></a> [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no |
149151
| <a name="input_runner_iam_role_managed_policy_arns"></a> [runner\_iam\_role\_managed\_policy\_arns](#input\_runner\_iam\_role\_managed\_policy\_arns) | Attach AWS or customer-managed IAM policies (by ARN) to the runner IAM role | `list(string)` | `[]` | no |

Diff for: modules/runners/main.tf

+8-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ resource "aws_launch_template" "runner" {
5757
}
5858
}
5959

60-
metadata_options {
61-
http_endpoint = "enabled"
62-
http_tokens = "required"
63-
http_put_response_hop_limit = 1
60+
dynamic "metadata_options" {
61+
for_each = var.metadata_options != null ? [var.metadata_options] : []
62+
63+
content {
64+
http_endpoint = metadata_options.value.http_endpoint
65+
http_tokens = metadata_options.value.http_tokens
66+
http_put_response_hop_limit = metadata_options.value.http_put_response_hop_limit
67+
}
6468
}
6569

6670
iam_instance_profile {

Diff for: modules/runners/variables.tf

+11
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,14 @@ variable "runner_ec2_tags" {
406406
type = map(string)
407407
default = {}
408408
}
409+
410+
variable "metadata_options" {
411+
description = "Metadata options for the ec2 runner instances."
412+
type = map(any)
413+
default = {
414+
http_endpoint = "enabled"
415+
http_tokens = "optional"
416+
http_put_response_hop_limit = 1
417+
}
418+
419+
}

Diff for: variables.tf

+11
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,14 @@ variable "runner_ec2_tags" {
450450
type = map(string)
451451
default = {}
452452
}
453+
454+
variable "runner_metadata_options" {
455+
description = "Metadata options for the ec2 runner instances."
456+
type = map(any)
457+
default = {
458+
http_endpoint = "enabled"
459+
http_tokens = "optional"
460+
http_put_response_hop_limit = 1
461+
}
462+
463+
}

0 commit comments

Comments
 (0)