Skip to content

Commit 105e554

Browse files
committed
Updates after rebase
1 parent c777eae commit 105e554

File tree

8 files changed

+78
-76
lines changed

8 files changed

+78
-76
lines changed

examples/default/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ module "runners" {
3232
webhook_secret = random_password.random.result
3333
}
3434

35-
webhook_lambda_zip = "lambdas-download/webhook.zip"
36-
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
37-
runners_lambda_zip = "lambdas-download/runners.zip"
38-
enable_organization_runners = false
39-
runner_extra_labels = "default,example"
35+
# webhook_lambda_zip = "lambdas-download/webhook.zip"
36+
# runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
37+
# runners_lambda_zip = "lambdas-download/runners.zip"
38+
enable_organization_runners = true
39+
runner_extra_labels = "default,example"
4040

4141
# enable access to the runners via SSM
4242
enable_ssm_on_runners = true
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { scaleDown } from './scale-runners/scale-down';
22

3-
43
export function run(): void {
5-
scaleDown();
4+
scaleDown();
65
}
76

87
run();
Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
1-
import { scaleUp } from './scale-runners/scale-up';
1+
import { scaleUp, ActionRequestMessage } from './scale-runners/scale-up';
22

33
const sqsEvent = {
4-
Records: [
5-
{
6-
messageId: 'e8d74d08-644e-42ca-bf82-a67daa6c4dad',
7-
// eslint-disable-next-line max-len
8-
receiptHandle: 'AQEBCpLYzDEKq4aKSJyFQCkJduSKZef8SJVOperbYyNhXqqnpFG5k74WygVAJ4O0+9nybRyeOFThvITOaS21/jeHiI5fgaM9YKuI0oGYeWCIzPQsluW5CMDmtvqv1aA8sXQ5n2x0L9MJkzgdIHTC3YWBFLQ2AxSveOyIHwW+cHLIFCAcZlOaaf0YtaLfGHGkAC4IfycmaijV8NSlzYgDuxrC9sIsWJ0bSvk5iT4ru/R4+0cjm7qZtGlc04k9xk5Fu6A+wRxMaIyiFRY+Ya19ykcevQldidmEjEWvN6CRToLgclk=',
9-
// eslint-disable-next-line max-len
10-
body: { "id": 19072, "repositoryName": "ErrBud", "repositoryOwner": "ActionsTest", "eventType": "check_run", "installationId": 5 },
11-
attributes: {
12-
ApproximateReceiveCount: '1',
13-
SentTimestamp: '1626450047230',
14-
SequenceNumber: '18863115285800432640',
15-
MessageGroupId: '19072',
16-
SenderId: 'AROA5KW7SQ6TTB3PW6WPH:cicddev-webhook',
17-
MessageDeduplicationId: '0c458eeb87b7f6d2607301268fd3bf33dd898a49ebd888754ff7db510c4bff1e',
18-
ApproximateFirstReceiveTimestamp: '1626450077251'
19-
},
20-
messageAttributes: {},
21-
md5OfBody: '4aef3bd70526e152e86426a0938cbec6',
22-
eventSource: 'aws:sqs',
23-
eventSourceARN: 'arn:aws:sqs:us-west-2:916370655143:cicddev-queued-builds.fifo',
24-
awsRegion: 'us-west-2'
25-
}
26-
]
4+
Records: [
5+
{
6+
messageId: 'e8d74d08-644e-42ca-bf82-a67daa6c4dad',
7+
receiptHandle:
8+
// eslint-disable-next-line max-len
9+
'AQEBCpLYzDEKq4aKSJyFQCkJduSKZef8SJVOperbYyNhXqqnpFG5k74WygVAJ4O0+9nybRyeOFThvITOaS21/jeHiI5fgaM9YKuI0oGYeWCIzPQsluW5CMDmtvqv1aA8sXQ5n2x0L9MJkzgdIHTC3YWBFLQ2AxSveOyIHwW+cHLIFCAcZlOaaf0YtaLfGHGkAC4IfycmaijV8NSlzYgDuxrC9sIsWJ0bSvk5iT4ru/R4+0cjm7qZtGlc04k9xk5Fu6A+wRxMaIyiFRY+Ya19ykcevQldidmEjEWvN6CRToLgclk=',
10+
body: {
11+
id: 19072,
12+
repositoryName: 'ErrBud',
13+
repositoryOwner: 'ActionsTest',
14+
eventType: 'check_run',
15+
installationId: 5,
16+
},
17+
attributes: {
18+
ApproximateReceiveCount: '1',
19+
SentTimestamp: '1626450047230',
20+
SequenceNumber: '18863115285800432640',
21+
MessageGroupId: '19072',
22+
SenderId: 'AROA5KW7SQ6TTB3PW6WPH:cicddev-webhook',
23+
MessageDeduplicationId: '0c458eeb87b7f6d2607301268fd3bf33dd898a49ebd888754ff7db510c4bff1e',
24+
ApproximateFirstReceiveTimestamp: '1626450077251',
25+
},
26+
messageAttributes: {},
27+
md5OfBody: '4aef3bd70526e152e86426a0938cbec6',
28+
eventSource: 'aws:sqs',
29+
eventSourceARN: 'arn:aws:sqs:us-west-2:916370655143:cicddev-queued-builds.fifo',
30+
awsRegion: 'us-west-2',
31+
},
32+
],
2733
};
2834
export function run(): void {
29-
scaleUp(sqsEvent.Records[0].eventSource, sqsEvent.Records[0].body);
35+
scaleUp(sqsEvent.Records[0].eventSource, sqsEvent.Records[0].body as ActionRequestMessage);
3036
}
3137

3238
run();

modules/runners/lambdas/runners/src/scale-runners/gh-auth.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ export async function createGithubAuth(
2121
authType: 'app' | 'installation',
2222
ghesApiUrl = '',
2323
): Promise<AppAuthentication> {
24-
2524
let authOptions: StrategyOptions = {
2625
appId: parseInt(await getParameterValue(process.env.PARAMETER_GITHUB_APP_ID_NAME)),
2726
privateKey: Buffer.from(
2827
await getParameterValue(process.env.PARAMETER_GITHUB_APP_KEY_BASE64_NAME),
29-
'base64')
30-
.toString(),
28+
'base64',
29+
).toString(),
3130
clientId: await getParameterValue(process.env.PARAMETER_GITHUB_APP_CLIENT_ID_NAME),
3231
clientSecret: await getParameterValue(process.env.PARAMETER_GITHUB_APP_CLIENT_SECRET_NAME),
3332
};
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
declare namespace NodeJS {
2-
export interface ProcessEnv {
3-
ENVIRONMENT: string
4-
SUBNET_IDS: string
5-
GHES_URL: string
6-
SCALE_DOWN_CONFIG: string
7-
MINIMUM_RUNNING_TIME_IN_MINUTES: string
8-
LAUNCH_TEMPLATE_NAME: string
9-
AWS_REGION: string
10-
PARAMETER_GITHUB_APP_CLIENT_ID_NAME: string
11-
PARAMETER_GITHUB_APP_CLIENT_SECRET_NAME: string
12-
PARAMETER_GITHUB_APP_ID_NAME: string
13-
PARAMETER_GITHUB_APP_KEY_BASE64_NAME: string
14-
}
2+
export interface ProcessEnv {
3+
ENVIRONMENT: string;
4+
SUBNET_IDS: string;
5+
GHES_URL: string;
6+
SCALE_DOWN_CONFIG: string;
7+
MINIMUM_RUNNING_TIME_IN_MINUTES: string;
8+
LAUNCH_TEMPLATE_NAME: string;
9+
AWS_REGION: string;
10+
PARAMETER_GITHUB_APP_CLIENT_ID_NAME: string;
11+
PARAMETER_GITHUB_APP_CLIENT_SECRET_NAME: string;
12+
PARAMETER_GITHUB_APP_ID_NAME: string;
13+
PARAMETER_GITHUB_APP_KEY_BASE64_NAME: string;
14+
}
1515
}

modules/runners/lambdas/runners/src/scale-runners/runners.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,6 @@ function getInstanceParams(
110110
}
111111

112112
function getSubnet(): string {
113-
const subnets = (process.env.SUBNET_IDS).split(',');
113+
const subnets = process.env.SUBNET_IDS.split(',');
114114
return subnets[Math.floor(Math.random() * subnets.length)];
115115
}

modules/runners/lambdas/runners/src/scale-runners/scale-down.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ function createGitHubClientForRunnerFactory(): (runner: RunnerInfo, orgLevel: bo
3939
console.debug(`[createGitHubClientForRunner] Cache miss for ${key}`);
4040
const installationId = orgLevel
4141
? (
42-
await githubClient.apps.getOrgInstallation({
43-
org: repo.repoOwner,
44-
})
45-
).data.id
42+
await githubClient.apps.getOrgInstallation({
43+
org: repo.repoOwner,
44+
})
45+
).data.id
4646
: (
47-
await githubClient.apps.getRepoInstallation({
48-
owner: repo.repoOwner,
49-
repo: repo.repoName,
50-
})
51-
).data.id;
47+
await githubClient.apps.getRepoInstallation({
48+
owner: repo.repoOwner,
49+
repo: repo.repoName,
50+
})
51+
).data.id;
5252
const ghAuth2 = await createGithubAuth(installationId, 'installation', ghesApiUrl);
5353
const octokit = await createOctoClient(ghAuth2.token, ghesApiUrl);
5454
cache.set(key, octokit);
@@ -82,12 +82,12 @@ function listGithubRunnersFactory(): (
8282
console.debug(`[listGithubRunners] Cache miss for ${key}`);
8383
const runners = enableOrgLevel
8484
? await client.paginate(client.actions.listSelfHostedRunnersForOrg, {
85-
org: repo.repoOwner,
86-
})
85+
org: repo.repoOwner,
86+
})
8787
: await client.paginate(client.actions.listSelfHostedRunnersForRepo, {
88-
owner: repo.repoOwner,
89-
repo: repo.repoName,
90-
});
88+
owner: repo.repoOwner,
89+
repo: repo.repoName,
90+
});
9191
cache.set(key, runners);
9292

9393
return runners;
@@ -110,14 +110,14 @@ async function removeRunner(
110110
try {
111111
const result = enableOrgLevel
112112
? await githubAppClient.actions.deleteSelfHostedRunnerFromOrg({
113-
runner_id: ghRunnerId,
114-
org: repo.repoOwner,
115-
})
113+
runner_id: ghRunnerId,
114+
org: repo.repoOwner,
115+
})
116116
: await githubAppClient.actions.deleteSelfHostedRunnerFromRepo({
117-
runner_id: ghRunnerId,
118-
owner: repo.repoOwner,
119-
repo: repo.repoName,
120-
});
117+
runner_id: ghRunnerId,
118+
owner: repo.repoOwner,
119+
repo: repo.repoName,
120+
});
121121

122122
if (result.status == 204) {
123123
await terminateRunner(ec2runner);

modules/webhook/webhook.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ resource "aws_lambda_function" "webhook" {
1212

1313
environment {
1414
variables = {
15-
ENVIRONMENT = var.environment
16-
KMS_KEY_ID = var.encryption.kms_key_id
17-
GITHUB_APP_WEBHOOK_SECRET = local.github_app_webhook_secret
18-
SQS_URL_WEBHOOK = var.sqs_build_queue.id
19-
REPOSITORY_WHITE_LIST = jsonencode(var.repository_white_list)
20-
RUNNER_LABELS = jsonencode(var.runner_extra_labels)
15+
ENVIRONMENT = var.environment
16+
SQS_URL_WEBHOOK = var.sqs_build_queue.id
17+
REPOSITORY_WHITE_LIST = jsonencode(var.repository_white_list)
18+
RUNNER_LABELS = jsonencode(var.runner_extra_labels)
2119
}
2220
}
2321

0 commit comments

Comments
 (0)