Skip to content

Commit 7319666

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

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
@@ -252,7 +252,6 @@ export async function createRunners(
252252
ghClient: Octokit,
253253
): Promise<string[]> {
254254
const instances = await createRunner({
255-
environment: ec2RunnerConfig.environment,
256255
runnerType: githubRunnerConfig.runnerType,
257256
runnerOwner: githubRunnerConfig.runnerOwner,
258257
numberOfRunners,
@@ -270,29 +269,9 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
270269
n_requests: payloads.length,
271270
});
272271

273-
const dynamicEc2TypesEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIGURATION, { default: false });
274-
const requestedInstanceType = payload.labels?.find(label => label.startsWith('ghr-ec2-'))?.replace('ghr-ec2-', '');
275-
276-
if (dynamicEc2TypesEnabled && requestedInstanceType) {
277-
logger.info(`Dynamic EC2 instance type requested: ${requestedInstanceType}`);
278-
}
279-
280-
// Store the requested instance type for use in createRunners
281-
const ec2Config = {
282-
...payload,
283-
requestedInstanceType: dynamicEc2TypesEnabled ? requestedInstanceType : undefined,
284-
};
285-
286272
const enableOrgLevel = yn(process.env.ENABLE_ORGANIZATION_RUNNERS, { default: true });
287273
const maximumRunners = parseInt(process.env.RUNNERS_MAXIMUM_COUNT || '3');
288-
289-
// Combine configured runner labels with dynamic EC2 instance type label if present
290-
let runnerLabels = process.env.RUNNER_LABELS || '';
291-
if (dynamicEc2TypesEnabled && requestedInstanceType) {
292-
const ec2Label = `ghr-ec2-${requestedInstanceType}`;
293-
runnerLabels = runnerLabels ? `${runnerLabels},${ec2Label}` : ec2Label;
294-
logger.debug(`Added dynamic EC2 instance type label: ${ec2Label} to runner config.`);
295-
}
274+
const runnerLabels = process.env.RUNNER_LABELS || '';
296275

297276
const runnerGroup = process.env.RUNNER_GROUP_NAME || 'Default';
298277
const environment = process.env.ENVIRONMENT;
@@ -301,6 +280,7 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
301280
const instanceTypes = process.env.INSTANCE_TYPES.split(',');
302281
const instanceTargetCapacityType = process.env.INSTANCE_TARGET_CAPACITY_TYPE;
303282
const ephemeralEnabled = yn(process.env.ENABLE_EPHEMERAL_RUNNERS, { default: false });
283+
const dynamicEc2ConfigEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIG, { default: false });
304284
const enableJitConfig = yn(process.env.ENABLE_JIT_CONFIG, { default: ephemeralEnabled });
305285
const disableAutoUpdate = yn(process.env.DISABLE_RUNNER_AUTOUPDATE, { default: false });
306286
const launchTemplateName = process.env.LAUNCH_TEMPLATE_NAME;
@@ -337,7 +317,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
337317
githubInstallationClient: Octokit;
338318
};
339319

340-
<<<<<<< HEAD
341320
const validMessages = new Map<string, MessagesWithClient>();
342321
const invalidMessages: string[] = [];
343322
for (const payload of payloads) {
@@ -346,41 +325,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
346325
logger.warn(
347326
'Event is not supported in combination with ephemeral runners. Please ensure you have enabled workflow_job events.',
348327
{ eventType, messageId },
349-
=======
350-
if (scaleUp) {
351-
logger.info(`Attempting to launch a new runner`);
352-
353-
await createRunners(
354-
{
355-
ephemeral,
356-
enableJitConfig,
357-
ghesBaseUrl,
358-
runnerLabels,
359-
runnerGroup,
360-
runnerNamePrefix,
361-
runnerOwner,
362-
runnerType,
363-
disableAutoUpdate,
364-
ssmTokenPath,
365-
ssmConfigPath,
366-
},
367-
{
368-
ec2instanceCriteria: {
369-
instanceTypes,
370-
targetCapacityType: instanceTargetCapacityType,
371-
maxSpotPrice: instanceMaxSpotPrice,
372-
instanceAllocationStrategy: instanceAllocationStrategy,
373-
},
374-
environment,
375-
launchTemplateName,
376-
subnets,
377-
amiIdSsmParameterName,
378-
tracingEnabled,
379-
onDemandFailoverOnError,
380-
},
381-
githubInstallationClient,
382-
ec2Config.requestedInstanceType,
383-
>>>>>>> 44737379 (feat: Add feature to enable dynamic instance types via workflow labels)
384328
);
385329

386330
invalidMessages.push(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)