diff --git a/README.md b/README.md index 591bfa20c4..894e2d95b5 100644 --- a/README.md +++ b/README.md @@ -411,6 +411,7 @@ In case the setup does not work as intended follow the trace of events: | [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no | | [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 | | [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. |
list(object({|
log_group_name = string
prefix_log_group = bool
file_path = string
log_stream_name = string
}))
[| no | +| [runner\_metadata\_options](#input\_runner\_metadata\_options) | Metadata options for the ec2 runner instances. | `map(any)` |
{
"file_path": "/var/log/messages",
"log_group_name": "messages",
"log_stream_name": "{instance_id}",
"prefix_log_group": true
},
{
"file_path": "/var/log/user-data.log",
"log_group_name": "user_data",
"log_stream_name": "{instance_id}",
"prefix_log_group": true
},
{
"file_path": "/home/ec2-user/actions-runner/_diag/Runner_**.log",
"log_group_name": "runner",
"log_stream_name": "{instance_id}",
"prefix_log_group": true
}
]
{| no | | [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 | | [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 | | [runners\_lambda\_zip](#input\_runners\_lambda\_zip) | File location of the lambda zip file for scaling runners. | `string` | `null` | no | diff --git a/main.tf b/main.tf index 3b7e154413..cab57a03a3 100644 --- a/main.tf +++ b/main.tf @@ -103,6 +103,7 @@ module "runners" { egress_rules = var.runner_egress_rules runner_additional_security_group_ids = var.runner_additional_security_group_ids volume_size = var.volume_size + metadata_options = var.runner_metadata_options lambda_s3_bucket = var.lambda_s3_bucket runners_lambda_s3_key = var.runners_lambda_s3_key diff --git a/modules/runners/README.md b/modules/runners/README.md index b7d52ff17e..f8e6eaa5af 100644 --- a/modules/runners/README.md +++ b/modules/runners/README.md @@ -136,6 +136,7 @@ No modules. | [log\_type](#input\_log\_type) | Logging format for lambda logging. Valid values are 'json', 'pretty', 'hidden'. | `string` | `"pretty"` | no | | [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 | | [market\_options](#input\_market\_options) | Market options for the action runner instances. | `string` | `"spot"` | no | +| [metadata\_options](#input\_metadata\_options) | Metadata options for the ec2 runner instances. | `map(any)` |
"http_endpoint": "enabled",
"http_put_response_hop_limit": 1,
"http_tokens": "optional"
}
{| no | | [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 | | [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)` |
"http_endpoint": "enabled",
"http_put_response_hop_limit": 1,
"http_tokens": "optional"
}
{| no | | [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. | [runner\_architecture](#input\_runner\_architecture) | The platform architecture of the runner instance\_type. | `string` | `"x64"` | no | | [runner\_as\_root](#input\_runner\_as\_root) | Run the action runner under the root user. | `bool` | `false` | no | | [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 | +| [runner\_ec2\_tags](#input\_runner\_ec2\_tags) | Map of tags that will be added to the launch template instance tag specificatons. | `map(string)` | `{}` | no | | [runner\_extra\_labels](#input\_runner\_extra\_labels) | Extra labels for the runners (GitHub). Separate each label by a comma | `string` | `""` | no | | [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no | | [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 --git a/modules/runners/main.tf b/modules/runners/main.tf index f187792334..de788f1b2f 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -57,10 +57,14 @@ resource "aws_launch_template" "runner" { } } - metadata_options { - http_endpoint = "enabled" - http_tokens = "required" - http_put_response_hop_limit = 1 + dynamic "metadata_options" { + for_each = var.metadata_options != null ? [var.metadata_options] : [] + + content { + http_endpoint = metadata_options.value.http_endpoint + http_tokens = metadata_options.value.http_tokens + http_put_response_hop_limit = metadata_options.value.http_put_response_hop_limit + } } iam_instance_profile { diff --git a/modules/runners/variables.tf b/modules/runners/variables.tf index f8c444c856..5e1e795385 100644 --- a/modules/runners/variables.tf +++ b/modules/runners/variables.tf @@ -406,3 +406,14 @@ variable "runner_ec2_tags" { type = map(string) default = {} } + +variable "metadata_options" { + description = "Metadata options for the ec2 runner instances." + type = map(any) + default = { + http_endpoint = "enabled" + http_tokens = "optional" + http_put_response_hop_limit = 1 + } + +} diff --git a/variables.tf b/variables.tf index d07064c5c0..778bcdadf7 100644 --- a/variables.tf +++ b/variables.tf @@ -450,3 +450,14 @@ variable "runner_ec2_tags" { type = map(string) default = {} } + +variable "runner_metadata_options" { + description = "Metadata options for the ec2 runner instances." + type = map(any) + default = { + http_endpoint = "enabled" + http_tokens = "optional" + http_put_response_hop_limit = 1 + } + +}
"name_runner": "",
"name_sg": ""
}