Skip to content

Commit 95c9b8a

Browse files
npalmgithub-aws-runners-pr|bot
and
github-aws-runners-pr|bot
authored
fix: define user agent (github-aws-runners#4394)
## Desription Setting the user-agent to call API call. By default the agent is set to `aws-github-runners` the value can be overriden. ## Notes cc: @SvanBoxel --------- Co-authored-by: github-aws-runners-pr|bot <github-aws-runners-pr[bot]@users.noreply.github.com>
1 parent 8a387b8 commit 95c9b8a

File tree

18 files changed

+34
-2
lines changed

18 files changed

+34
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ Join our discord community via [this invite link](https://discord.gg/bxgXW8jJGh)
221221
| <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 |
222222
| <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 |
223223
| <a name="input_tracing_config"></a> [tracing\_config](#input\_tracing\_config) | Configuration for lambda tracing. | <pre>object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> })</pre> | `{}` | no |
224+
| <a name="input_user_agent"></a> [user\_agent](#input\_user\_agent) | User agent used for API calls by lambda functions. | `string` | `"github-aws-runners"` | no |
224225
| <a name="input_userdata_content"></a> [userdata\_content](#input\_userdata\_content) | Alternative user-data content, replacing the templated one. By providing your own user\_data you have to take care of installing all required software, including the action runner and registering the runner. Be-aware configuration paramaters in SSM as well as tags are treated as internals. Changes will not trigger a breaking release. | `string` | `null` | no |
225226
| <a name="input_userdata_post_install"></a> [userdata\_post\_install](#input\_userdata\_post\_install) | Script to be ran after the GitHub Actions runner is installed on the EC2 instances | `string` | `""` | no |
226227
| <a name="input_userdata_pre_install"></a> [userdata\_pre\_install](#input\_userdata\_pre\_install) | Script to be ran before the GitHub Actions runner is installed on the EC2 instances | `string` | `""` | no |

lambdas/functions/control-plane/src/github/auth.ts

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export async function createOctokitClient(token: string, ghesApiUrl = ''): Promi
2929

3030
return new CustomOctokit({
3131
...ocktokitOptions,
32+
userAgent: process.env.USER_AGENT || 'github-aws-runners',
3233
throttle: {
3334
onRateLimit: (retryAfter: number, options: Required<EndpointDefaults>) => {
3435
logger.warn(

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ module "runners" {
256256

257257
ghes_url = var.ghes_url
258258
ghes_ssl_verify = var.ghes_ssl_verify
259+
user_agent = var.user_agent
259260

260261
kms_key_arn = var.kms_key_arn
261262

modules/multi-runner/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ module "multi-runner" {
178178
| <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 |
179179
| <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 |
180180
| <a name="input_tracing_config"></a> [tracing\_config](#input\_tracing\_config) | Configuration for lambda tracing. | <pre>object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> })</pre> | `{}` | no |
181+
| <a name="input_user_agent"></a> [user\_agent](#input\_user\_agent) | User agent used for API calls by lambda functions. | `string` | `"github-aws-runners"` | no |
181182
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC for security groups of the action runners. | `string` | n/a | yes |
182183
| <a name="input_webhook_lambda_apigateway_access_log_settings"></a> [webhook\_lambda\_apigateway\_access\_log\_settings](#input\_webhook\_lambda\_apigateway\_access\_log\_settings) | Access log settings for webhook API gateway. | <pre>object({<br/> destination_arn = string<br/> format = string<br/> })</pre> | `null` | no |
183184
| <a name="input_webhook_lambda_memory_size"></a> [webhook\_lambda\_memory\_size](#input\_webhook\_lambda\_memory\_size) | Memory size limit in MB for webhook lambda. | `number` | `256` | no |

modules/multi-runner/runners.tf

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ module "runners" {
102102

103103
ghes_url = var.ghes_url
104104
ghes_ssl_verify = var.ghes_ssl_verify
105+
user_agent = var.user_agent
105106

106107
kms_key_arn = var.kms_key_arn
107108

modules/multi-runner/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,9 @@ variable "eventbridge" {
671671

672672
default = {}
673673
}
674+
675+
variable "user_agent" {
676+
description = "User agent used for API calls by lambda functions."
677+
type = string
678+
default = "github-aws-runners"
679+
}

modules/runners/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ yarn run dist
223223
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | n/a | yes |
224224
| <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. | `map(string)` | `{}` | no |
225225
| <a name="input_tracing_config"></a> [tracing\_config](#input\_tracing\_config) | Configuration for lambda tracing. | <pre>object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> })</pre> | `{}` | no |
226+
| <a name="input_user_agent"></a> [user\_agent](#input\_user\_agent) | User agent used for API calls. | `string` | `null` | no |
226227
| <a name="input_userdata_content"></a> [userdata\_content](#input\_userdata\_content) | Alternative user-data content, replacing the templated one. By providing your own user\_data you have to take care of installing all required software, including the action runner and registering the runner. Be-aware configuration paramaters in SSM as well as tags are treated as internals. Changes will not trigger a breaking release. | `string` | `null` | no |
227228
| <a name="input_userdata_post_install"></a> [userdata\_post\_install](#input\_userdata\_post\_install) | User-data script snippet to insert after GitHub action runner install | `string` | `""` | no |
228229
| <a name="input_userdata_pre_install"></a> [userdata\_pre\_install](#input\_userdata\_pre\_install) | User-data script snippet to insert before GitHub action runner install | `string` | `""` | no |

modules/runners/job-retry/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The module is an inner module and used by the runner module when the opt-in feat
4242

4343
| Name | Description | Type | Default | Required |
4444
|------|-------------|------|---------|:--------:|
45-
| <a name="input_config"></a> [config](#input\_config) | Configuration for the spot termination watcher lambda function.<br/><br/>`aws_partition`: Partition for the base arn if not 'aws'<br/>`architecture`: AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86\_64' functions.<br/>`environment_variables`: Environment variables for the lambda.<br/>`enable_organization_runners`: Enable organization runners.<br/>`enable_metric`: Enable metric for the lambda. If `spot_warning` is set to true, the lambda will emit a metric when it detects a spot termination warning.<br/>'ghes\_url': Optional GitHub Enterprise Server URL.<br/>'github\_app\_parameters': Parameter Store for GitHub App Parameters.<br/>'kms\_key\_arn': Optional CMK Key ARN instead of using the default AWS managed key.<br/>`lambda_principals`: Add extra principals to the role created for execution of the lambda, e.g. for local testing.<br/>`lambda_tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`log_level`: Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'.<br/>`logging_kms_key_id`: Specifies the kms key id to encrypt the logs with<br/>`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.<br/>`memory_size`: Memory size linit in MB of the lambda.<br/>`metrics`: Configuration to enable metrics creation by the lambda.<br/>`prefix`: The prefix used for naming resources.<br/>`role_path`: The path that will be added to the role, if not set the environment name will be used.<br/>`role_permissions_boundary`: Permissions boundary that will be added to the created role for the lambda.<br/>`runtime`: AWS Lambda runtime.<br/>`s3_bucket`: S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly.<br/>`s3_key`: S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas.<br/>`s3_object_version`: S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket.<br/>`security_group_ids`: List of security group IDs associated with the Lambda function.<br/>'sqs\_build\_queue': SQS queue for build events to re-publish job request.<br/>`subnet_ids`: List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`.<br/>`tag_filters`: Map of tags that will be used to filter the resources to be tracked. Only for which all tags are present and starting with the same value as the value in the map will be tracked.<br/>`tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`timeout`: Time out of the lambda in seconds.<br/>`tracing_config`: Configuration for lambda tracing.<br/>`zip`: File location of the lambda zip file. | <pre>object({<br/> aws_partition = optional(string, null)<br/> architecture = optional(string, null)<br/> enable_organization_runners = bool<br/> environment_variables = optional(map(string), {})<br/> ghes_url = optional(string, null)<br/> github_app_parameters = object({<br/> key_base64 = map(string)<br/> id = map(string)<br/> })<br/> kms_key_arn = optional(string, null)<br/> lambda_tags = optional(map(string), {})<br/> log_level = optional(string, null)<br/> logging_kms_key_id = optional(string, null)<br/> logging_retention_in_days = optional(number, null)<br/> memory_size = optional(number, null)<br/> metrics = optional(object({<br/> enable = optional(bool, false)<br/> namespace = optional(string, null)<br/> metric = optional(object({<br/> enable_github_app_rate_limit = optional(bool, true)<br/> enable_job_retry = optional(bool, true)<br/> }), {})<br/> }), {})<br/> prefix = optional(string, null)<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })), [])<br/> queue_encryption = optional(object({<br/> kms_data_key_reuse_period_seconds = optional(number, null)<br/> kms_master_key_id = optional(string, null)<br/> sqs_managed_sse_enabled = optional(bool, true)<br/> }), {})<br/> role_path = optional(string, null)<br/> role_permissions_boundary = optional(string, null)<br/> runtime = optional(string, null)<br/> security_group_ids = optional(list(string), [])<br/> subnet_ids = optional(list(string), [])<br/> s3_bucket = optional(string, null)<br/> s3_key = optional(string, null)<br/> s3_object_version = optional(string, null)<br/> sqs_build_queue = object({<br/> url = string<br/> arn = string<br/> })<br/> tags = optional(map(string), {})<br/> timeout = optional(number, 30)<br/> tracing_config = optional(object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> }), {})<br/> zip = optional(string, null)<br/> })</pre> | n/a | yes |
45+
| <a name="input_config"></a> [config](#input\_config) | Configuration for the spot termination watcher lambda function.<br/><br/>`aws_partition`: Partition for the base arn if not 'aws'<br/>`architecture`: AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86\_64' functions.<br/>`environment_variables`: Environment variables for the lambda.<br/>`enable_organization_runners`: Enable organization runners.<br/>`enable_metric`: Enable metric for the lambda. If `spot_warning` is set to true, the lambda will emit a metric when it detects a spot termination warning.<br/>'ghes\_url': Optional GitHub Enterprise Server URL.<br/>'user\_agent': Optional User-Agent header for GitHub API requests.<br/>'github\_app\_parameters': Parameter Store for GitHub App Parameters.<br/>'kms\_key\_arn': Optional CMK Key ARN instead of using the default AWS managed key.<br/>`lambda_principals`: Add extra principals to the role created for execution of the lambda, e.g. for local testing.<br/>`lambda_tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`log_level`: Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'.<br/>`logging_kms_key_id`: Specifies the kms key id to encrypt the logs with<br/>`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.<br/>`memory_size`: Memory size linit in MB of the lambda.<br/>`metrics`: Configuration to enable metrics creation by the lambda.<br/>`prefix`: The prefix used for naming resources.<br/>`role_path`: The path that will be added to the role, if not set the environment name will be used.<br/>`role_permissions_boundary`: Permissions boundary that will be added to the created role for the lambda.<br/>`runtime`: AWS Lambda runtime.<br/>`s3_bucket`: S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly.<br/>`s3_key`: S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas.<br/>`s3_object_version`: S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket.<br/>`security_group_ids`: List of security group IDs associated with the Lambda function.<br/>'sqs\_build\_queue': SQS queue for build events to re-publish job request.<br/>`subnet_ids`: List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`.<br/>`tag_filters`: Map of tags that will be used to filter the resources to be tracked. Only for which all tags are present and starting with the same value as the value in the map will be tracked.<br/>`tags`: Map of tags that will be added to created resources. By default resources will be tagged with name and environment.<br/>`timeout`: Time out of the lambda in seconds.<br/>`tracing_config`: Configuration for lambda tracing.<br/>`zip`: File location of the lambda zip file. | <pre>object({<br/> aws_partition = optional(string, null)<br/> architecture = optional(string, null)<br/> enable_organization_runners = bool<br/> environment_variables = optional(map(string), {})<br/> ghes_url = optional(string, null)<br/> user_agent = optional(string, null)<br/> github_app_parameters = object({<br/> key_base64 = map(string)<br/> id = map(string)<br/> })<br/> kms_key_arn = optional(string, null)<br/> lambda_tags = optional(map(string), {})<br/> log_level = optional(string, null)<br/> logging_kms_key_id = optional(string, null)<br/> logging_retention_in_days = optional(number, null)<br/> memory_size = optional(number, null)<br/> metrics = optional(object({<br/> enable = optional(bool, false)<br/> namespace = optional(string, null)<br/> metric = optional(object({<br/> enable_github_app_rate_limit = optional(bool, true)<br/> enable_job_retry = optional(bool, true)<br/> }), {})<br/> }), {})<br/> prefix = optional(string, null)<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })), [])<br/> queue_encryption = optional(object({<br/> kms_data_key_reuse_period_seconds = optional(number, null)<br/> kms_master_key_id = optional(string, null)<br/> sqs_managed_sse_enabled = optional(bool, true)<br/> }), {})<br/> role_path = optional(string, null)<br/> role_permissions_boundary = optional(string, null)<br/> runtime = optional(string, null)<br/> security_group_ids = optional(list(string), [])<br/> subnet_ids = optional(list(string), [])<br/> s3_bucket = optional(string, null)<br/> s3_key = optional(string, null)<br/> s3_object_version = optional(string, null)<br/> sqs_build_queue = object({<br/> url = string<br/> arn = string<br/> })<br/> tags = optional(map(string), {})<br/> timeout = optional(number, 30)<br/> tracing_config = optional(object({<br/> mode = optional(string, null)<br/> capture_http_requests = optional(bool, false)<br/> capture_error = optional(bool, false)<br/> }), {})<br/> zip = optional(string, null)<br/> })</pre> | n/a | yes |
4646

4747
## Outputs
4848

modules/runners/job-retry/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ locals {
77
ENABLE_METRIC_JOB_RETRY = var.config.metrics.enable && var.config.metrics.metric.enable_job_retry
88
ENABLE_METRIC_GITHUB_APP_RATE_LIMIT = var.config.metrics.enable && var.config.metrics.metric.enable_github_app_rate_limit
99
GHES_URL = var.config.ghes_url
10+
USER_AGENT = var.config.user_agent
1011
JOB_QUEUE_SCALE_UP_URL = var.config.sqs_build_queue.url
1112
PARAMETER_GITHUB_APP_ID_NAME = var.config.github_app_parameters.id.name
1213
PARAMETER_GITHUB_APP_KEY_BASE64_NAME = var.config.github_app_parameters.key_base64.name

modules/runners/job-retry/variables.tf

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ variable "config" {
88
`enable_organization_runners`: Enable organization runners.
99
`enable_metric`: Enable metric for the lambda. If `spot_warning` is set to true, the lambda will emit a metric when it detects a spot termination warning.
1010
'ghes_url': Optional GitHub Enterprise Server URL.
11+
'user_agent': Optional User-Agent header for GitHub API requests.
1112
'github_app_parameters': Parameter Store for GitHub App Parameters.
1213
'kms_key_arn': Optional CMK Key ARN instead of using the default AWS managed key.
1314
`lambda_principals`: Add extra principals to the role created for execution of the lambda, e.g. for local testing.
@@ -39,6 +40,7 @@ variable "config" {
3940
enable_organization_runners = bool
4041
environment_variables = optional(map(string), {})
4142
ghes_url = optional(string, null)
43+
user_agent = optional(string, null)
4244
github_app_parameters = object({
4345
key_base64 = map(string)
4446
id = map(string)

modules/runners/pool.tf

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module "pool" {
99
ssl_verify = var.ghes_ssl_verify
1010
url = var.ghes_url
1111
}
12+
user_agent = var.user_agent
1213
github_app_parameters = var.github_app_parameters
1314
instance_allocation_strategy = var.instance_allocation_strategy
1415
instance_max_spot_price = var.instance_max_spot_price

0 commit comments

Comments
 (0)