Skip to content

Commit 6be3726

Browse files
github-aws-runners-pr|botedersonbrilhante
authored andcommitted
docs: auto update terraform docs
1 parent 5c23012 commit 6be3726

8 files changed

Lines changed: 10 additions & 64 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Join our discord community via [this invite link](https://discord.gg/bxgXW8jJGh)
121121
| <a name="input_disable_runner_autoupdate"></a> [disable\_runner\_autoupdate](#input\_disable\_runner\_autoupdate) | Disable the auto update of the github runner agent. Be aware there is a grace period of 30 days, see also the [GitHub article](https://github.blog/changelog/2022-02-01-github-actions-self-hosted-runners-can-now-disable-automatic-updates/) | `bool` | `false` | no |
122122
| <a name="input_enable_ami_housekeeper"></a> [enable\_ami\_housekeeper](#input\_enable\_ami\_housekeeper) | Option to disable the lambda to clean up old AMIs. | `bool` | `false` | no |
123123
| <a name="input_enable_cloudwatch_agent"></a> [enable\_cloudwatch\_agent](#input\_enable\_cloudwatch\_agent) | Enables the cloudwatch agent on the ec2 runner instances. The runner uses a default config that can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
124+
| <a name="input_enable_dynamic_ec2_types"></a> [enable\_dynamic\_ec2\_types](#input\_enable\_dynamic\_ec2\_types) | Enable dynamic EC2 instance types based on workflow job labels. When enabled, jobs can request specific instance types via the 'gh-ec2-instance-type' label (e.g., 'gh-ec2-t3.large'). | `bool` | `false` | no |
124125
| <a name="input_enable_ephemeral_runners"></a> [enable\_ephemeral\_runners](#input\_enable\_ephemeral\_runners) | Enable ephemeral runners, runners will only be used once. | `bool` | `false` | no |
125126
| <a name="input_enable_jit_config"></a> [enable\_jit\_config](#input\_enable\_jit\_config) | Overwrite the default behavior for JIT configuration. By default JIT configuration is enabled for ephemeral runners and disabled for non-ephemeral runners. In case of GHES check first if the JIT config API is available. In case you are upgrading from 3.x to 4.x you can set `enable_jit_config` to `false` to avoid a breaking change when having your own AMI. | `bool` | `null` | no |
126127
| <a name="input_enable_job_queued_check"></a> [enable\_job\_queued\_check](#input\_enable\_job\_queued\_check) | Only scale if the job event received by the scale up lambda is in the queued state. By default enabled for non ephemeral runners and disabled for ephemeral. Set this variable to overwrite the default behavior. | `bool` | `null` | no |

lambdas/functions/control-plane/src/scale-runners/scale-up.ts

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ export async function createRunners(
251251
ghClient: Octokit,
252252
): Promise<string[]> {
253253
const instances = await createRunner({
254-
environment: ec2RunnerConfig.environment,
255254
runnerType: githubRunnerConfig.runnerType,
256255
runnerOwner: githubRunnerConfig.runnerOwner,
257256
numberOfRunners,
@@ -291,29 +290,9 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
291290
n_requests: payloads.length,
292291
});
293292

294-
const dynamicEc2TypesEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIGURATION, { default: false });
295-
const requestedInstanceType = payload.labels?.find(label => label.startsWith('ghr-ec2-'))?.replace('ghr-ec2-', '');
296-
297-
if (dynamicEc2TypesEnabled && requestedInstanceType) {
298-
logger.info(`Dynamic EC2 instance type requested: ${requestedInstanceType}`);
299-
}
300-
301-
// Store the requested instance type for use in createRunners
302-
const ec2Config = {
303-
...payload,
304-
requestedInstanceType: dynamicEc2TypesEnabled ? requestedInstanceType : undefined,
305-
};
306-
307293
const enableOrgLevel = yn(process.env.ENABLE_ORGANIZATION_RUNNERS, { default: true });
308294
const maximumRunners = parseInt(process.env.RUNNERS_MAXIMUM_COUNT || '3');
309-
310-
// Combine configured runner labels with dynamic EC2 instance type label if present
311-
let runnerLabels = process.env.RUNNER_LABELS || '';
312-
if (dynamicEc2TypesEnabled && requestedInstanceType) {
313-
const ec2Label = `ghr-ec2-${requestedInstanceType}`;
314-
runnerLabels = runnerLabels ? `${runnerLabels},${ec2Label}` : ec2Label;
315-
logger.debug(`Added dynamic EC2 instance type label: ${ec2Label} to runner config.`);
316-
}
295+
const runnerLabels = process.env.RUNNER_LABELS || '';
317296

318297
const runnerGroup = process.env.RUNNER_GROUP_NAME || 'Default';
319298
const environment = process.env.ENVIRONMENT;
@@ -322,6 +301,7 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
322301
const instanceTypes = process.env.INSTANCE_TYPES.split(',');
323302
const instanceTargetCapacityType = process.env.INSTANCE_TARGET_CAPACITY_TYPE;
324303
const ephemeralEnabled = yn(process.env.ENABLE_EPHEMERAL_RUNNERS, { default: false });
304+
const dynamicEc2ConfigEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIG, { default: false });
325305
const enableJitConfig = yn(process.env.ENABLE_JIT_CONFIG, { default: ephemeralEnabled });
326306
const disableAutoUpdate = yn(process.env.DISABLE_RUNNER_AUTOUPDATE, { default: false });
327307
const launchTemplateName = process.env.LAUNCH_TEMPLATE_NAME;
@@ -358,7 +338,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
358338
githubInstallationClient: Octokit;
359339
};
360340

361-
<<<<<<< HEAD
362341
const validMessages = new Map<string, MessagesWithClient>();
363342
const rejectedMessageIds = new Set<string>();
364343
for (const payload of payloads) {
@@ -367,41 +346,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
367346
logger.warn(
368347
'Event is not supported in combination with ephemeral runners. Please ensure you have enabled workflow_job events.',
369348
{ eventType, messageId },
370-
=======
371-
if (scaleUp) {
372-
logger.info(`Attempting to launch a new runner`);
373-
374-
await createRunners(
375-
{
376-
ephemeral,
377-
enableJitConfig,
378-
ghesBaseUrl,
379-
runnerLabels,
380-
runnerGroup,
381-
runnerNamePrefix,
382-
runnerOwner,
383-
runnerType,
384-
disableAutoUpdate,
385-
ssmTokenPath,
386-
ssmConfigPath,
387-
},
388-
{
389-
ec2instanceCriteria: {
390-
instanceTypes,
391-
targetCapacityType: instanceTargetCapacityType,
392-
maxSpotPrice: instanceMaxSpotPrice,
393-
instanceAllocationStrategy: instanceAllocationStrategy,
394-
},
395-
environment,
396-
launchTemplateName,
397-
subnets,
398-
amiIdSsmParameterName,
399-
tracingEnabled,
400-
onDemandFailoverOnError,
401-
},
402-
githubInstallationClient,
403-
ec2Config.requestedInstanceType,
404-
>>>>>>> 44737379 (feat: Add feature to enable dynamic instance types via workflow labels)
405349
);
406350

407351
rejectedMessageIds.add(messageId);

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ module "runners" {
185185
github_app_parameters = local.github_app_parameters
186186
enable_organization_runners = var.enable_organization_runners
187187
enable_ephemeral_runners = var.enable_ephemeral_runners
188-
enable_dynamic_ec2_configuration = var.enable_dynamic_ec2_configuration
188+
enable_dynamic_ec2_config = var.enable_dynamic_ec2_config
189189
enable_job_queued_check = var.enable_job_queued_check
190190
enable_jit_config = var.enable_jit_config
191191
enable_on_demand_failover_for_errors = var.enable_runner_on_demand_failover_for_errors

modules/multi-runner/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ variable "multi_runner_config" {
7777
disable_runner_autoupdate = optional(bool, false)
7878
ebs_optimized = optional(bool, false)
7979
enable_ephemeral_runners = optional(bool, false)
80-
enable_dynamic_ec2_configuration = optional(bool, false)
80+
enable_dynamic_ec2_config = optional(bool, false)
8181
enable_job_queued_check = optional(bool, null)
8282
enable_on_demand_failover_for_errors = optional(list(string), [])
8383
scale_errors = optional(list(string), [
@@ -208,7 +208,7 @@ variable "multi_runner_config" {
208208
disable_runner_autoupdate: "Disable the auto update of the github runner agent. Be aware there is a grace period of 30 days, see also the [GitHub article](https://github.blog/changelog/2022-02-01-github-actions-self-hosted-runners-can-now-disable-automatic-updates/)"
209209
ebs_optimized: "The EC2 EBS optimized configuration."
210210
enable_ephemeral_runners: "Enable ephemeral runners, runners will only be used once."
211-
enable_dynamic_ec2_configuration: "Enable dynamic EC2 configs based on workflow job labels. When enabled, jobs can request specific configs via the 'gh-ec2-<config type key>:<config type value>' label (e.g., 'gh-ec2-instance-type:t3.large')."
211+
enable_dynamic_ec2_config: "Enable dynamic EC2 configs based on workflow job labels. When enabled, jobs can request specific configs via the 'gh-ec2-<config type key>:<config type value>' label (e.g., 'gh-ec2-instance-type:t3.large')."
212212
enable_job_queued_check: "(Optional) Only scale if the job event received by the scale up lambda is is in the state queued. By default enabled for non ephemeral runners and disabled for ephemeral. Set this variable to overwrite the default behavior."
213213
enable_on_demand_failover_for_errors: "Enable on-demand failover. For example to fall back to on demand when no spot capacity is available the variable can be set to `InsufficientInstanceCapacity`. When not defined the default behavior is to retry later."
214214
scale_errors: "List of aws error codes that should trigger retry during scale up. This list will replace the default errors defined in the variable `defaultScaleErrors` in https://github.com/github-aws-runners/terraform-aws-github-runner/blob/main/lambdas/functions/control-plane/src/aws/runners.ts"

modules/runners/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ yarn run dist
149149
| <a name="input_ebs_optimized"></a> [ebs\_optimized](#input\_ebs\_optimized) | The EC2 EBS optimized configuration. | `bool` | `false` | no |
150150
| <a name="input_egress_rules"></a> [egress\_rules](#input\_egress\_rules) | List of egress rules for the GitHub runner instances. | <pre>list(object({<br/> cidr_blocks = list(string)<br/> ipv6_cidr_blocks = list(string)<br/> prefix_list_ids = list(string)<br/> from_port = number<br/> protocol = string<br/> security_groups = list(string)<br/> self = bool<br/> to_port = number<br/> description = string<br/> }))</pre> | <pre>[<br/> {<br/> "cidr_blocks": [<br/> "0.0.0.0/0"<br/> ],<br/> "description": null,<br/> "from_port": 0,<br/> "ipv6_cidr_blocks": [<br/> "::/0"<br/> ],<br/> "prefix_list_ids": null,<br/> "protocol": "-1",<br/> "security_groups": null,<br/> "self": null,<br/> "to_port": 0<br/> }<br/>]</pre> | no |
151151
| <a name="input_enable_cloudwatch_agent"></a> [enable\_cloudwatch\_agent](#input\_enable\_cloudwatch\_agent) | Enabling the cloudwatch agent on the ec2 runner instances, the runner contains default config. Configuration can be overridden via `cloudwatch_config`. | `bool` | `true` | no |
152+
| <a name="input_enable_dynamic_ec2_types"></a> [enable\_dynamic\_ec2\_types](#input\_enable\_dynamic\_ec2\_types) | Enable dynamic EC2 instance types based on workflow job labels. When enabled, jobs can request specific instance types via the 'gh:ec2:instance-type' label. | `bool` | `false` | no |
152153
| <a name="input_enable_ephemeral_runners"></a> [enable\_ephemeral\_runners](#input\_enable\_ephemeral\_runners) | Enable ephemeral runners, runners will only be used once. | `bool` | `false` | no |
153154
| <a name="input_enable_jit_config"></a> [enable\_jit\_config](#input\_enable\_jit\_config) | Overwrite the default behavior for JIT configuration. By default JIT configuration is enabled for ephemeral runners and disabled for non-ephemeral runners. In case of GHES check first if the JIT config API is available. In case you are upgrading from 3.x to 4.x you can set `enable_jit_config` to `false` to avoid a breaking change when having your own AMI. | `bool` | `null` | no |
154155
| <a name="input_enable_job_queued_check"></a> [enable\_job\_queued\_check](#input\_enable\_job\_queued\_check) | Only scale if the job event received by the scale up lambda is is in the state queued. By default enabled for non ephemeral runners and disabled for ephemeral. Set this variable to overwrite the default behavior. | `bool` | `null` | no |

modules/runners/scale-up.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ resource "aws_lambda_function" "scale_up" {
2828
AMI_ID_SSM_PARAMETER_NAME = local.ami_id_ssm_parameter_name
2929
DISABLE_RUNNER_AUTOUPDATE = var.disable_runner_autoupdate
3030
ENABLE_EPHEMERAL_RUNNERS = var.enable_ephemeral_runners
31-
ENABLE_DYNAMIC_EC2_CONFIGURATION = var.enable_dynamic_ec2_configuration
31+
ENABLE_DYNAMIC_EC2_CONFIG = var.enable_dynamic_ec2_config
3232
ENABLE_JIT_CONFIG = var.enable_jit_config
3333
ENABLE_JOB_QUEUED_CHECK = local.enable_job_queued_check
3434
ENABLE_METRIC_GITHUB_APP_RATE_LIMIT = var.metrics.enable && var.metrics.metric.enable_github_app_rate_limit

modules/runners/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ variable "enable_ephemeral_runners" {
532532
default = false
533533
}
534534

535-
variable "enable_dynamic_ec2_configuration" {
535+
variable "enable_dynamic_ec2_config" {
536536
description = "Enable dynamic EC2 instance types based on workflow job labels. When enabled, jobs can request specific instance types via the 'gh:ec2:instance-type' label."
537537
type = bool
538538
default = false

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ variable "enable_ephemeral_runners" {
673673
default = false
674674
}
675675

676-
variable "enable_dynamic_ec2_configuration" {
676+
variable "enable_dynamic_ec2_config" {
677677
description = "Enable dynamic EC2 configs based on workflow job labels. When enabled, jobs can request specific configs via the 'gh-ec2-<config type key>:<config type value>' label (e.g., 'gh-ec2-instance-type:t3.large')."
678678
type = bool
679679
default = false

0 commit comments

Comments
 (0)