Skip to content

Commit c637bb0

Browse files
github-aws-runners-pr|botedersonbrilhante
authored andcommitted
docs: auto update terraform docs
1 parent aa9df6d commit c637bb0

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
@@ -253,7 +253,6 @@ export async function createRunners(
253253
ghClient: Octokit,
254254
): Promise<string[]> {
255255
const instances = await createRunner({
256-
environment: ec2RunnerConfig.environment,
257256
runnerType: githubRunnerConfig.runnerType,
258257
runnerOwner: githubRunnerConfig.runnerOwner,
259258
numberOfRunners,
@@ -293,29 +292,9 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
293292
n_requests: payloads.length,
294293
});
295294

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

320299
const runnerGroup = process.env.RUNNER_GROUP_NAME || 'Default';
321300
const environment = process.env.ENVIRONMENT;
@@ -324,6 +303,7 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
324303
const instanceTypes = process.env.INSTANCE_TYPES.split(',');
325304
const instanceTargetCapacityType = process.env.INSTANCE_TARGET_CAPACITY_TYPE;
326305
const ephemeralEnabled = yn(process.env.ENABLE_EPHEMERAL_RUNNERS, { default: false });
306+
const dynamicEc2ConfigEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIG, { default: false });
327307
const enableJitConfig = yn(process.env.ENABLE_JIT_CONFIG, { default: ephemeralEnabled });
328308
const disableAutoUpdate = yn(process.env.DISABLE_RUNNER_AUTOUPDATE, { default: false });
329309
const launchTemplateName = process.env.LAUNCH_TEMPLATE_NAME;
@@ -360,7 +340,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
360340
githubInstallationClient: Octokit;
361341
};
362342

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

409353
rejectedMessageIds.add(messageId);

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ module "runners" {
184184
github_app_parameters = local.github_app_parameters
185185
enable_organization_runners = var.enable_organization_runners
186186
enable_ephemeral_runners = var.enable_ephemeral_runners
187-
enable_dynamic_ec2_configuration = var.enable_dynamic_ec2_configuration
187+
enable_dynamic_ec2_config = var.enable_dynamic_ec2_config
188188
enable_job_queued_check = var.enable_job_queued_check
189189
enable_jit_config = var.enable_jit_config
190190
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), [
@@ -207,7 +207,7 @@ variable "multi_runner_config" {
207207
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/)"
208208
ebs_optimized: "The EC2 EBS optimized configuration."
209209
enable_ephemeral_runners: "Enable ephemeral runners, runners will only be used once."
210-
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')."
210+
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')."
211211
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."
212212
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."
213213
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
@@ -520,7 +520,7 @@ variable "enable_ephemeral_runners" {
520520
default = false
521521
}
522522

523-
variable "enable_dynamic_ec2_configuration" {
523+
variable "enable_dynamic_ec2_config" {
524524
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."
525525
type = bool
526526
default = false

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ variable "enable_ephemeral_runners" {
661661
default = false
662662
}
663663

664-
variable "enable_dynamic_ec2_configuration" {
664+
variable "enable_dynamic_ec2_config" {
665665
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')."
666666
type = bool
667667
default = false

0 commit comments

Comments
 (0)