Skip to content

Commit cc915e2

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

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
@@ -217,7 +217,6 @@ export async function createRunners(
217217
ghClient: Octokit,
218218
): Promise<string[]> {
219219
const instances = await createRunner({
220-
environment: ec2RunnerConfig.environment,
221220
runnerType: githubRunnerConfig.runnerType,
222221
runnerOwner: githubRunnerConfig.runnerOwner,
223222
numberOfRunners,
@@ -235,29 +234,9 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
235234
n_requests: payloads.length,
236235
});
237236

238-
const dynamicEc2TypesEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIGURATION, { default: false });
239-
const requestedInstanceType = payload.labels?.find(label => label.startsWith('ghr-ec2-'))?.replace('ghr-ec2-', '');
240-
241-
if (dynamicEc2TypesEnabled && requestedInstanceType) {
242-
logger.info(`Dynamic EC2 instance type requested: ${requestedInstanceType}`);
243-
}
244-
245-
// Store the requested instance type for use in createRunners
246-
const ec2Config = {
247-
...payload,
248-
requestedInstanceType: dynamicEc2TypesEnabled ? requestedInstanceType : undefined,
249-
};
250-
251237
const enableOrgLevel = yn(process.env.ENABLE_ORGANIZATION_RUNNERS, { default: true });
252238
const maximumRunners = parseInt(process.env.RUNNERS_MAXIMUM_COUNT || '3');
253-
254-
// Combine configured runner labels with dynamic EC2 instance type label if present
255-
let runnerLabels = process.env.RUNNER_LABELS || '';
256-
if (dynamicEc2TypesEnabled && requestedInstanceType) {
257-
const ec2Label = `ghr-ec2-${requestedInstanceType}`;
258-
runnerLabels = runnerLabels ? `${runnerLabels},${ec2Label}` : ec2Label;
259-
logger.debug(`Added dynamic EC2 instance type label: ${ec2Label} to runner config.`);
260-
}
239+
const runnerLabels = process.env.RUNNER_LABELS || '';
261240

262241
const runnerGroup = process.env.RUNNER_GROUP_NAME || 'Default';
263242
const environment = process.env.ENVIRONMENT;
@@ -266,6 +245,7 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
266245
const instanceTypes = process.env.INSTANCE_TYPES.split(',');
267246
const instanceTargetCapacityType = process.env.INSTANCE_TARGET_CAPACITY_TYPE;
268247
const ephemeralEnabled = yn(process.env.ENABLE_EPHEMERAL_RUNNERS, { default: false });
248+
const dynamicEc2ConfigEnabled = yn(process.env.ENABLE_DYNAMIC_EC2_CONFIG, { default: false });
269249
const enableJitConfig = yn(process.env.ENABLE_JIT_CONFIG, { default: ephemeralEnabled });
270250
const disableAutoUpdate = yn(process.env.DISABLE_RUNNER_AUTOUPDATE, { default: false });
271251
const launchTemplateName = process.env.LAUNCH_TEMPLATE_NAME;
@@ -298,7 +278,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
298278
githubInstallationClient: Octokit;
299279
};
300280

301-
<<<<<<< HEAD
302281
const validMessages = new Map<string, MessagesWithClient>();
303282
const invalidMessages: string[] = [];
304283
for (const payload of payloads) {
@@ -307,41 +286,6 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
307286
logger.warn(
308287
'Event is not supported in combination with ephemeral runners. Please ensure you have enabled workflow_job events.',
309288
{ eventType, messageId },
310-
=======
311-
if (scaleUp) {
312-
logger.info(`Attempting to launch a new runner`);
313-
314-
await createRunners(
315-
{
316-
ephemeral,
317-
enableJitConfig,
318-
ghesBaseUrl,
319-
runnerLabels,
320-
runnerGroup,
321-
runnerNamePrefix,
322-
runnerOwner,
323-
runnerType,
324-
disableAutoUpdate,
325-
ssmTokenPath,
326-
ssmConfigPath,
327-
},
328-
{
329-
ec2instanceCriteria: {
330-
instanceTypes,
331-
targetCapacityType: instanceTargetCapacityType,
332-
maxSpotPrice: instanceMaxSpotPrice,
333-
instanceAllocationStrategy: instanceAllocationStrategy,
334-
},
335-
environment,
336-
launchTemplateName,
337-
subnets,
338-
amiIdSsmParameterName,
339-
tracingEnabled,
340-
onDemandFailoverOnError,
341-
},
342-
githubInstallationClient,
343-
ec2Config.requestedInstanceType,
344-
>>>>>>> 44737379 (feat: Add feature to enable dynamic instance types via workflow labels)
345289
);
346290

347291
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)