@cloudsnorkel/cdk-github-runners 0.14.20 → 0.14.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +27 -27
- package/README.md +1 -0
- package/assets/delete-failed-runner.lambda/index.js +3248 -11227
- package/assets/idle-runner-repear.lambda/index.js +3224 -11221
- package/assets/image-builders/aws-image-builder/delete-resources.lambda/index.js +12 -2
- package/assets/image-builders/aws-image-builder/filter-failed-builds.lambda/index.js +4 -1
- package/assets/image-builders/build-image.lambda/index.js +21 -4
- package/assets/providers/ami-root-device.lambda/index.js +45 -10
- package/assets/providers/update-lambda.lambda/index.js +6 -1
- package/assets/setup.lambda/index.js +1762 -4645
- package/assets/status.lambda/index.js +2412 -10615
- package/assets/token-retriever.lambda/index.js +3228 -11221
- package/assets/webhook-handler.lambda/index.js +3264 -11236
- package/assets/webhook-redelivery.lambda/index.js +3220 -11221
- package/lib/access.js +1 -1
- package/lib/delete-failed-runner.lambda.js +22 -4
- package/lib/idle-runner-repear.lambda.js +1 -1
- package/lib/image-builders/api.js +1 -1
- package/lib/image-builders/aws-image-builder/base-image.js +2 -2
- package/lib/image-builders/aws-image-builder/builder.js +3 -3
- package/lib/image-builders/aws-image-builder/delete-resources.lambda.js +6 -2
- package/lib/image-builders/aws-image-builder/deprecated/ami.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/container.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
- package/lib/image-builders/aws-image-builder/filter-failed-builds.lambda.js +5 -2
- package/lib/image-builders/build-image.lambda.js +15 -4
- package/lib/image-builders/codebuild-deprecated.js +1 -1
- package/lib/image-builders/components.d.ts +12 -1
- package/lib/image-builders/components.js +48 -10
- package/lib/image-builders/static.js +1 -1
- package/lib/lambda-github.d.ts +14 -7
- package/lib/lambda-github.js +34 -8
- package/lib/lambda-helpers.js +8 -2
- package/lib/providers/ami-root-device.lambda.js +39 -10
- package/lib/providers/codebuild.js +2 -2
- package/lib/providers/common.js +3 -3
- package/lib/providers/composite.js +1 -1
- package/lib/providers/ec2.js +2 -2
- package/lib/providers/ecs.js +1 -1
- package/lib/providers/fargate.js +2 -2
- package/lib/providers/lambda.js +2 -2
- package/lib/providers/update-lambda.lambda.js +7 -2
- package/lib/runner.js +1 -1
- package/lib/secrets.js +1 -1
- package/lib/setup.lambda.js +7 -4
- package/lib/status.lambda.js +17 -8
- package/lib/token-retriever.lambda.js +8 -2
- package/lib/webhook-handler.lambda.js +39 -12
- package/lib/webhook-redelivery.lambda.js +1 -1
- package/package.json +5 -5
|
@@ -41,7 +41,13 @@ async function customResourceRespond(event, responseStatus, reason, physicalReso
|
|
|
41
41
|
NoEcho: false,
|
|
42
42
|
Data: data
|
|
43
43
|
});
|
|
44
|
-
console.log(
|
|
44
|
+
console.log({
|
|
45
|
+
notice: "Responding to CloudFormation custom resource",
|
|
46
|
+
status: responseStatus,
|
|
47
|
+
reason,
|
|
48
|
+
physicalResourceId,
|
|
49
|
+
responseBody
|
|
50
|
+
});
|
|
45
51
|
const parsedUrl = require("url").parse(event.ResponseURL);
|
|
46
52
|
const requestOptions = {
|
|
47
53
|
hostname: parsedUrl.hostname,
|
|
@@ -171,6 +177,7 @@ async function deleteResources(props) {
|
|
|
171
177
|
async function handler(event, _context) {
|
|
172
178
|
try {
|
|
173
179
|
console.log({
|
|
180
|
+
notice: "CloudFormation custom resource request",
|
|
174
181
|
...event,
|
|
175
182
|
ResponseURL: "..."
|
|
176
183
|
});
|
|
@@ -188,7 +195,10 @@ async function handler(event, _context) {
|
|
|
188
195
|
break;
|
|
189
196
|
}
|
|
190
197
|
} catch (e) {
|
|
191
|
-
console.error(
|
|
198
|
+
console.error({
|
|
199
|
+
notice: "Failed to delete Image Builder resources",
|
|
200
|
+
error: `${e}`
|
|
201
|
+
});
|
|
192
202
|
await customResourceRespond(event, "FAILED", e.message || "Internal Error", "FAIL", {});
|
|
193
203
|
}
|
|
194
204
|
}
|
|
@@ -26,7 +26,10 @@ module.exports = __toCommonJS(filter_failed_builds_lambda_exports);
|
|
|
26
26
|
var import_client_sns = require("@aws-sdk/client-sns");
|
|
27
27
|
var sns = new import_client_sns.SNSClient();
|
|
28
28
|
async function handler(event) {
|
|
29
|
-
console.log(
|
|
29
|
+
console.log({
|
|
30
|
+
notice: "Received SNS event",
|
|
31
|
+
recordCount: event.Records.length
|
|
32
|
+
});
|
|
30
33
|
for (const record of event.Records) {
|
|
31
34
|
let message = JSON.parse(record.Sns.Message);
|
|
32
35
|
if (message.state.status === "FAILED") {
|
|
@@ -39,7 +39,13 @@ async function customResourceRespond(event, responseStatus, reason, physicalReso
|
|
|
39
39
|
NoEcho: false,
|
|
40
40
|
Data: data
|
|
41
41
|
});
|
|
42
|
-
console.log(
|
|
42
|
+
console.log({
|
|
43
|
+
notice: "Responding to CloudFormation custom resource",
|
|
44
|
+
status: responseStatus,
|
|
45
|
+
reason,
|
|
46
|
+
physicalResourceId,
|
|
47
|
+
responseBody
|
|
48
|
+
});
|
|
43
49
|
const parsedUrl = require("url").parse(event.ResponseURL);
|
|
44
50
|
const requestOptions = {
|
|
45
51
|
hostname: parsedUrl.hostname,
|
|
@@ -66,12 +72,20 @@ async function customResourceRespond(event, responseStatus, reason, physicalReso
|
|
|
66
72
|
var codebuild = new import_client_codebuild.CodeBuildClient();
|
|
67
73
|
async function handler(event, context) {
|
|
68
74
|
try {
|
|
69
|
-
console.log({
|
|
75
|
+
console.log({
|
|
76
|
+
notice: "CloudFormation custom resource request",
|
|
77
|
+
...event,
|
|
78
|
+
ResponseURL: "..."
|
|
79
|
+
});
|
|
70
80
|
const props = event.ResourceProperties;
|
|
71
81
|
switch (event.RequestType) {
|
|
72
82
|
case "Create":
|
|
73
83
|
case "Update":
|
|
74
|
-
console.log(
|
|
84
|
+
console.log({
|
|
85
|
+
notice: "Starting CodeBuild project",
|
|
86
|
+
projectName: props.ProjectName,
|
|
87
|
+
repoName: props.RepoName
|
|
88
|
+
});
|
|
75
89
|
const cbRes = await codebuild.send(new import_client_codebuild.StartBuildCommand({
|
|
76
90
|
projectName: props.ProjectName,
|
|
77
91
|
environmentVariablesOverride: [
|
|
@@ -89,7 +103,10 @@ async function handler(event, context) {
|
|
|
89
103
|
break;
|
|
90
104
|
}
|
|
91
105
|
} catch (e) {
|
|
92
|
-
console.error(
|
|
106
|
+
console.error({
|
|
107
|
+
notice: "Failed to start CodeBuild project",
|
|
108
|
+
error: `${e}`
|
|
109
|
+
});
|
|
93
110
|
await customResourceRespond(event, "FAILED", e.message || "Internal Error", context.logStreamName, {});
|
|
94
111
|
}
|
|
95
112
|
}
|
|
@@ -41,7 +41,13 @@ async function customResourceRespond(event, responseStatus, reason, physicalReso
|
|
|
41
41
|
NoEcho: false,
|
|
42
42
|
Data: data
|
|
43
43
|
});
|
|
44
|
-
console.log(
|
|
44
|
+
console.log({
|
|
45
|
+
notice: "Responding to CloudFormation custom resource",
|
|
46
|
+
status: responseStatus,
|
|
47
|
+
reason,
|
|
48
|
+
physicalResourceId,
|
|
49
|
+
responseBody
|
|
50
|
+
});
|
|
45
51
|
const parsedUrl = require("url").parse(event.ResponseURL);
|
|
46
52
|
const requestOptions = {
|
|
47
53
|
hostname: parsedUrl.hostname,
|
|
@@ -79,25 +85,39 @@ async function handleAmi(event, ami) {
|
|
|
79
85
|
await customResourceRespond(event, "FAILED", `${ami} has no root device`, "ERROR", {});
|
|
80
86
|
return;
|
|
81
87
|
}
|
|
82
|
-
console.log(
|
|
88
|
+
console.log({
|
|
89
|
+
notice: "Resolved AMI root device",
|
|
90
|
+
ami,
|
|
91
|
+
rootDevice
|
|
92
|
+
});
|
|
83
93
|
await customResourceRespond(event, "SUCCESS", "OK", rootDevice, {});
|
|
84
94
|
return;
|
|
85
95
|
}
|
|
86
96
|
async function handler(event, context) {
|
|
87
97
|
try {
|
|
88
|
-
console.log({
|
|
98
|
+
console.log({
|
|
99
|
+
notice: "CloudFormation custom resource request",
|
|
100
|
+
...event,
|
|
101
|
+
ResponseURL: "..."
|
|
102
|
+
});
|
|
89
103
|
const ami = event.ResourceProperties.Ami;
|
|
90
104
|
switch (event.RequestType) {
|
|
91
105
|
case "Create":
|
|
92
106
|
case "Update":
|
|
93
107
|
if (ami.startsWith("ami-")) {
|
|
94
|
-
console.log(
|
|
108
|
+
console.log({
|
|
109
|
+
notice: "Checking AMI",
|
|
110
|
+
ami
|
|
111
|
+
});
|
|
95
112
|
await handleAmi(event, ami);
|
|
96
113
|
break;
|
|
97
114
|
}
|
|
98
115
|
if (ami.startsWith("resolve:ssm:")) {
|
|
99
116
|
const ssmParam = ami.substring("resolve:ssm:".length);
|
|
100
|
-
console.log(
|
|
117
|
+
console.log({
|
|
118
|
+
notice: "Checking SSM",
|
|
119
|
+
ssmParam
|
|
120
|
+
});
|
|
101
121
|
const ssmValue = (await ssm.send(new import_client_ssm.GetParameterCommand({ Name: ssmParam }))).Parameter?.Value;
|
|
102
122
|
if (!ssmValue) {
|
|
103
123
|
await customResourceRespond(event, "FAILED", `${ami} has no value`, "ERROR", {});
|
|
@@ -108,7 +128,10 @@ async function handler(event, context) {
|
|
|
108
128
|
}
|
|
109
129
|
if (ami.startsWith("ssm:")) {
|
|
110
130
|
const ssmParam = ami.substring("ssm:".length);
|
|
111
|
-
console.log(
|
|
131
|
+
console.log({
|
|
132
|
+
notice: "Checking SSM",
|
|
133
|
+
ssmParam
|
|
134
|
+
});
|
|
112
135
|
const ssmValue = (await ssm.send(new import_client_ssm.GetParameterCommand({ Name: ssmParam }))).Parameter?.Value;
|
|
113
136
|
if (!ssmValue) {
|
|
114
137
|
await customResourceRespond(event, "FAILED", `${ami} has no value`, "ERROR", {});
|
|
@@ -118,7 +141,10 @@ async function handler(event, context) {
|
|
|
118
141
|
break;
|
|
119
142
|
}
|
|
120
143
|
if (ami.startsWith("lt-")) {
|
|
121
|
-
console.log(
|
|
144
|
+
console.log({
|
|
145
|
+
notice: "Checking Launch Template",
|
|
146
|
+
launchTemplateId: ami
|
|
147
|
+
});
|
|
122
148
|
const lts = await ec2.send(new import_client_ec2.DescribeLaunchTemplateVersionsCommand({ LaunchTemplateId: ami, Versions: ["$Latest"] }));
|
|
123
149
|
if (lts.LaunchTemplateVersions?.length !== 1) {
|
|
124
150
|
await customResourceRespond(event, "FAILED", `${ami} doesn't exist`, "ERROR", {});
|
|
@@ -132,7 +158,10 @@ async function handler(event, context) {
|
|
|
132
158
|
break;
|
|
133
159
|
}
|
|
134
160
|
if (ami.match("^arn:aws[^:]*:imagebuilder:[^:]+:[^:]+:image/.*$")) {
|
|
135
|
-
console.log(
|
|
161
|
+
console.log({
|
|
162
|
+
notice: "Checking Image Builder",
|
|
163
|
+
imageBuildVersionArn: ami
|
|
164
|
+
});
|
|
136
165
|
const img = await ib.send(new import_client_imagebuilder.GetImageCommand({ imageBuildVersionArn: ami }));
|
|
137
166
|
const actualAmi = img.image?.outputResources?.amis?.[0]?.image;
|
|
138
167
|
if (!actualAmi) {
|
|
@@ -145,12 +174,18 @@ async function handler(event, context) {
|
|
|
145
174
|
await customResourceRespond(event, "FAILED", `Unknown type of AMI ${ami}`, "ERROR", {});
|
|
146
175
|
break;
|
|
147
176
|
case "Delete":
|
|
148
|
-
console.log(
|
|
177
|
+
console.log({
|
|
178
|
+
notice: "Nothing to delete",
|
|
179
|
+
ami
|
|
180
|
+
});
|
|
149
181
|
await customResourceRespond(event, "SUCCESS", "OK", event.PhysicalResourceId, {});
|
|
150
182
|
break;
|
|
151
183
|
}
|
|
152
184
|
} catch (e) {
|
|
153
|
-
console.error(
|
|
185
|
+
console.error({
|
|
186
|
+
notice: "Failed to resolve AMI root device",
|
|
187
|
+
error: `${e}`
|
|
188
|
+
});
|
|
154
189
|
await customResourceRespond(event, "FAILED", e.message || "Internal Error", context.logStreamName, {});
|
|
155
190
|
}
|
|
156
191
|
}
|
|
@@ -29,7 +29,12 @@ function sleep(ms) {
|
|
|
29
29
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
30
30
|
}
|
|
31
31
|
async function handler(event) {
|
|
32
|
-
console.log(
|
|
32
|
+
console.log({
|
|
33
|
+
notice: "Updating Lambda function code from container image",
|
|
34
|
+
lambdaName: event.lambdaName,
|
|
35
|
+
repositoryUri: event.repositoryUri,
|
|
36
|
+
repositoryTag: event.repositoryTag
|
|
37
|
+
});
|
|
33
38
|
while (true) {
|
|
34
39
|
try {
|
|
35
40
|
await lambda.send(new import_client_lambda.UpdateFunctionCodeCommand({
|