Skip to content

Commit e8bd9aa

Browse files
authored
Merge branch 'main' into stu/fix_job_retry
2 parents dac6aff + e80baa2 commit e8bd9aa

File tree

29 files changed

+986
-905
lines changed

29 files changed

+986
-905
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ Join our discord community via [this invite link](https://discord.gg/bxgXW8jJGh)
163163
| <a name="input_matcher_config_parameter_store_tier"></a> [matcher\_config\_parameter\_store\_tier](#input\_matcher\_config\_parameter\_store\_tier) | The tier of the parameter store for the matcher configuration. Valid values are `Standard`, and `Advanced`. | `string` | `"Standard"` | no |
164164
| <a name="input_metrics"></a> [metrics](#input\_metrics) | Configuration for metrics created by the module, by default disabled to avoid additional costs. When metrics are enable all metrics are created unless explicit configured otherwise. | <pre>object({<br/> enable = optional(bool, false)<br/> namespace = optional(string, "GitHub Runners")<br/> metric = optional(object({<br/> enable_github_app_rate_limit = optional(bool, true)<br/> enable_job_retry = optional(bool, true)<br/> enable_spot_termination_warning = optional(bool, true)<br/> }), {})<br/> })</pre> | `{}` | no |
165165
| <a name="input_minimum_running_time_in_minutes"></a> [minimum\_running\_time\_in\_minutes](#input\_minimum\_running\_time\_in\_minutes) | The time an ec2 action runner should be running at minimum before terminated, if not busy. | `number` | `null` | no |
166+
| <a name="input_parameter_store_tags"></a> [parameter\_store\_tags](#input\_parameter\_store\_tags) | Map of tags that will be added to all the SSM Parameter Store parameters created by the Lambda function. | `map(string)` | `{}` | no |
166167
| <a name="input_pool_config"></a> [pool\_config](#input\_pool\_config) | The configuration for updating the pool. The `pool_size` to adjust to by the events triggered by the `schedule_expression`. For example you can configure a cron expression for weekdays to adjust the pool to 10 and another expression for the weekend to adjust the pool to 1. Use `schedule_expression_timezone` to override the schedule time zone (defaults to UTC). | <pre>list(object({<br/> schedule_expression = string<br/> schedule_expression_timezone = optional(string)<br/> size = number<br/> }))</pre> | `[]` | no |
167168
| <a name="input_pool_lambda_memory_size"></a> [pool\_lambda\_memory\_size](#input\_pool\_lambda\_memory\_size) | Memory size limit for scale-up lambda. | `number` | `512` | no |
168169
| <a name="input_pool_lambda_reserved_concurrent_executions"></a> [pool\_lambda\_reserved\_concurrent\_executions](#input\_pool\_lambda\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no |

lambdas/functions/ami-housekeeper/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"all": "yarn build && yarn format && yarn lint && yarn test"
1818
},
1919
"devDependencies": {
20-
"@aws-sdk/types": "^3.957.0",
20+
"@aws-sdk/types": "^3.965.0",
2121
"@types/aws-lambda": "^8.10.159",
2222
"@vercel/ncc": "^0.38.4",
2323
"aws-sdk-client-mock": "^4.1.0",
@@ -26,8 +26,8 @@
2626
"dependencies": {
2727
"@aws-github-runner/aws-powertools-util": "*",
2828
"@aws-github-runner/aws-ssm-util": "*",
29-
"@aws-sdk/client-ec2": "^3.958.0",
30-
"@aws-sdk/client-ssm": "^3.958.0",
29+
"@aws-sdk/client-ec2": "^3.965.0",
30+
"@aws-sdk/client-ssm": "^3.965.0",
3131
"cron-parser": "^5.4.0"
3232
},
3333
"nx": {

lambdas/functions/control-plane/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"all": "yarn build && yarn format && yarn lint && yarn test"
1818
},
1919
"devDependencies": {
20-
"@aws-sdk/types": "^3.957.0",
20+
"@aws-sdk/types": "^3.965.0",
2121
"@octokit/types": "^16.0.0",
2222
"@types/aws-lambda": "^8.10.159",
2323
"@types/node": "^22.19.3",
@@ -33,8 +33,8 @@
3333
"@aws-github-runner/aws-powertools-util": "*",
3434
"@aws-github-runner/aws-ssm-util": "*",
3535
"@aws-lambda-powertools/parameters": "^2.30.0",
36-
"@aws-sdk/client-ec2": "^3.958.0",
37-
"@aws-sdk/client-sqs": "^3.960.0",
36+
"@aws-sdk/client-ec2": "^3.965.0",
37+
"@aws-sdk/client-sqs": "^3.965.0",
3838
"@middy/core": "^6.4.5",
3939
"@octokit/auth-app": "8.1.2",
4040
"@octokit/core": "7.0.6",

lambdas/functions/control-plane/src/pool/pool.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { bootTimeExceeded, listEC2Runners } from '../aws/runners';
66
import { RunnerList } from '../aws/runners.d';
77
import { createGithubAppAuth, createGithubInstallationAuth, createOctokitClient } from '../github/auth';
88
import { createRunners, getGitHubEnterpriseApiUrl } from '../scale-runners/scale-up';
9+
import { validateSsmParameterStoreTags } from '../scale-runners/scale-up';
910

1011
const logger = createChildLogger('pool');
1112

@@ -41,6 +42,10 @@ export async function adjust(event: PoolEvent): Promise<void> {
4142
const onDemandFailoverOnError = process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS
4243
? (JSON.parse(process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS) as [string])
4344
: [];
45+
const ssmParameterStoreTags: { Key: string; Value: string }[] =
46+
process.env.SSM_PARAMETER_STORE_TAGS && process.env.SSM_PARAMETER_STORE_TAGS.trim() !== ''
47+
? validateSsmParameterStoreTags(process.env.SSM_PARAMETER_STORE_TAGS)
48+
: [];
4449
const scaleErrors = JSON.parse(process.env.SCALE_ERRORS) as [string];
4550

4651
const { ghesApiUrl, ghesBaseUrl } = getGitHubEnterpriseApiUrl();
@@ -82,6 +87,7 @@ export async function adjust(event: PoolEvent): Promise<void> {
8287
disableAutoUpdate: disableAutoUpdate,
8388
ssmTokenPath,
8489
ssmConfigPath,
90+
ssmParameterStoreTags,
8591
},
8692
{
8793
ec2instanceCriteria: {

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

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ interface CreateGitHubRunnerConfig {
5252
disableAutoUpdate: boolean;
5353
ssmTokenPath: string;
5454
ssmConfigPath: string;
55+
ssmParameterStoreTags: { Key: string; Value: string }[];
5556
}
5657

5758
interface CreateEC2RunnerConfig {
@@ -91,6 +92,37 @@ function generateRunnerServiceConfig(githubRunnerConfig: CreateGitHubRunnerConfi
9192
return config;
9293
}
9394

95+
export function validateSsmParameterStoreTags(tagsJson: string): { Key: string; Value: string }[] {
96+
try {
97+
const tags = JSON.parse(tagsJson);
98+
99+
if (!Array.isArray(tags)) {
100+
throw new Error('Tags must be an array');
101+
}
102+
103+
if (tags.length === 0) {
104+
return [];
105+
}
106+
107+
tags.forEach((tag, index) => {
108+
if (typeof tag !== 'object' || tag === null) {
109+
throw new Error(`Tag at index ${index} must be an object`);
110+
}
111+
if (!tag.Key || typeof tag.Key !== 'string' || tag.Key.trim() === '') {
112+
throw new Error(`Tag at index ${index} has missing or invalid 'Key' property`);
113+
}
114+
if (!Object.prototype.hasOwnProperty.call(tag, 'Value') || typeof tag.Value !== 'string') {
115+
throw new Error(`Tag at index ${index} has missing or invalid 'Value' property`);
116+
}
117+
});
118+
119+
return tags;
120+
} catch (err) {
121+
logger.error('Invalid SSM_PARAMETER_STORE_TAGS format', { error: err });
122+
throw new Error(`Failed to parse SSM_PARAMETER_STORE_TAGS: ${(err as Error).message}`);
123+
}
124+
}
125+
94126
async function getGithubRunnerRegistrationToken(githubRunnerConfig: CreateGitHubRunnerConfig, ghClient: Octokit) {
95127
const registrationToken =
96128
githubRunnerConfig.runnerType === 'Org'
@@ -184,6 +216,9 @@ async function getRunnerGroupId(githubRunnerConfig: CreateGitHubRunnerConfig, gh
184216
`${githubRunnerConfig.ssmConfigPath}/runner-group/${githubRunnerConfig.runnerGroup}`,
185217
runnerGroupId.toString(),
186218
false,
219+
{
220+
tags: githubRunnerConfig.ssmParameterStoreTags,
221+
},
187222
);
188223
} catch (err) {
189224
logger.debug('Error storing runner group id in SSM Parameter Store', err as Error);
@@ -257,6 +292,10 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
257292
const onDemandFailoverOnError = process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS
258293
? (JSON.parse(process.env.ENABLE_ON_DEMAND_FAILOVER_FOR_ERRORS) as [string])
259294
: [];
295+
const ssmParameterStoreTags: { Key: string; Value: string }[] =
296+
process.env.SSM_PARAMETER_STORE_TAGS && process.env.SSM_PARAMETER_STORE_TAGS.trim() !== ''
297+
? validateSsmParameterStoreTags(process.env.SSM_PARAMETER_STORE_TAGS)
298+
: [];
260299
const scaleErrors = JSON.parse(process.env.SCALE_ERRORS) as [string];
261300

262301
const { ghesApiUrl, ghesBaseUrl } = getGitHubEnterpriseApiUrl();
@@ -429,6 +468,7 @@ export async function scaleUp(payloads: ActionRequestMessageSQS[]): Promise<stri
429468
disableAutoUpdate,
430469
ssmTokenPath,
431470
ssmConfigPath,
471+
ssmParameterStoreTags,
432472
},
433473
{
434474
ec2instanceCriteria: {
@@ -531,7 +571,7 @@ async function createRegistrationTokenConfig(
531571

532572
for (const instance of instances) {
533573
await putParameter(`${githubRunnerConfig.ssmTokenPath}/${instance}`, runnerServiceConfig.join(' '), true, {
534-
tags: [{ Key: 'InstanceId', Value: instance }],
574+
tags: [{ Key: 'InstanceId', Value: instance }, ...githubRunnerConfig.ssmParameterStoreTags],
535575
});
536576
if (isDelay) {
537577
// Delay to prevent AWS ssm rate limits by being within the max throughput limit
@@ -589,7 +629,7 @@ async function createJitConfig(githubRunnerConfig: CreateGitHubRunnerConfig, ins
589629
instance: instance,
590630
});
591631
await putParameter(`${githubRunnerConfig.ssmTokenPath}/${instance}`, runnerConfig.data.encoded_jit_config, true, {
592-
tags: [{ Key: 'InstanceId', Value: instance }],
632+
tags: [{ Key: 'InstanceId', Value: instance }, ...githubRunnerConfig.ssmParameterStoreTags],
593633
});
594634
if (isDelay) {
595635
// Delay to prevent AWS ssm rate limits by being within the max throughput limit

lambdas/functions/gh-agent-syncer/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"all": "yarn build && yarn format && yarn lint && yarn test"
1818
},
1919
"devDependencies": {
20-
"@aws-sdk/types": "^3.957.0",
20+
"@aws-sdk/types": "^3.965.0",
2121
"@types/aws-lambda": "^8.10.159",
2222
"@types/node": "^22.19.3",
2323
"@types/request": "^2.48.13",
@@ -28,8 +28,8 @@
2828
},
2929
"dependencies": {
3030
"@aws-github-runner/aws-powertools-util": "*",
31-
"@aws-sdk/client-s3": "^3.958.0",
32-
"@aws-sdk/lib-storage": "^3.958.0",
31+
"@aws-sdk/client-s3": "^3.965.0",
32+
"@aws-sdk/lib-storage": "^3.965.0",
3333
"@middy/core": "^6.4.5",
3434
"@octokit/rest": "22.0.1",
3535
"axios": "^1.13.2"

lambdas/functions/termination-watcher/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"all": "yarn build && yarn format && yarn lint && yarn test"
1616
},
1717
"devDependencies": {
18-
"@aws-sdk/types": "^3.957.0",
18+
"@aws-sdk/types": "^3.965.0",
1919
"@types/aws-lambda": "^8.10.159",
2020
"@types/node": "^22.19.3",
2121
"@vercel/ncc": "^0.38.4",
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"@aws-github-runner/aws-powertools-util": "*",
27-
"@aws-sdk/client-ec2": "^3.958.0",
27+
"@aws-sdk/client-ec2": "^3.965.0",
2828
"@middy/core": "^6.4.5"
2929
},
3030
"nx": {

lambdas/functions/webhook/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"all": "yarn build && yarn format && yarn lint && yarn test"
1818
},
1919
"devDependencies": {
20-
"@aws-sdk/client-eventbridge": "^3.958.0",
20+
"@aws-sdk/client-eventbridge": "^3.965.0",
2121
"@octokit/webhooks-types": "^7.6.1",
2222
"@types/aws-lambda": "^8.10.159",
2323
"@types/express": "^5.0.3",
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"@aws-github-runner/aws-powertools-util": "*",
3232
"@aws-github-runner/aws-ssm-util": "*",
33-
"@aws-sdk/client-sqs": "^3.960.0",
33+
"@aws-sdk/client-sqs": "^3.965.0",
3434
"@middy/core": "^6.4.5",
3535
"@octokit/rest": "22.0.1",
3636
"@octokit/types": "^16.0.0",

lambdas/libs/aws-ssm-util/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
"all": "yarn build && yarn format && yarn lint && yarn test"
1616
},
1717
"devDependencies": {
18-
"@aws-sdk/types": "^3.957.0",
18+
"@aws-sdk/types": "^3.965.0",
1919
"@types/aws-lambda": "^8.10.159",
2020
"@types/node": "^22.19.3",
2121
"aws-sdk-client-mock": "^4.1.0",
2222
"aws-sdk-client-mock-jest": "^4.1.0"
2323
},
2424
"dependencies": {
2525
"@aws-github-runner/aws-powertools-util": "*",
26-
"@aws-sdk/client-ssm": "^3.958.0"
26+
"@aws-sdk/client-ssm": "^3.965.0"
2727
},
2828
"nx": {
2929
"includedScripts": [

lambdas/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@nx/js": "^22.2.7",
3030
"@nx/vite": "^22.2.7",
3131
"@swc-node/register": "~1.11.1",
32-
"@swc/core": "~1.15.0",
32+
"@swc/core": "~1.15.8",
3333
"@swc/helpers": "~0.5.17",
3434
"@trivago/prettier-plugin-sort-imports": "^6.0.0",
3535
"@typescript-eslint/eslint-plugin": "^8.47.0",

0 commit comments

Comments
 (0)