@evident-ai/runner-cdk 3.5.2-dev.a72611d → 3.5.2-dev.bbd799b
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/README.md +91 -40
- package/dist/controller-lambda/handler.js +74 -79
- package/dist/evident-scale-to-zero-construct.js +7 -0
- package/dist/image-version-pruner-lambda/handler.js +28250 -0
- package/dist/image-version-reporter-lambda/handler.js +15 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/microvm/constants.d.ts +1 -1
- package/dist/microvm/constants.js +7 -4
- package/dist/microvm/construct.d.ts +12 -8
- package/dist/microvm/construct.js +42 -33
- package/dist/microvm/controller/{doorbell.d.ts → doorbell-request.d.ts} +6 -6
- package/dist/microvm/controller/{doorbell.js → doorbell-request.js} +2 -2
- package/dist/microvm/controller/handle-doorbell.d.ts +2 -2
- package/dist/microvm/controller/handle-doorbell.js +62 -62
- package/dist/microvm/image/stage-context.d.ts +13 -38
- package/dist/microvm/image/stage-context.js +31 -118
- package/dist/microvm/image-version-pruner/construct.d.ts +13 -0
- package/dist/microvm/image-version-pruner/construct.js +79 -0
- package/dist/microvm/image-version-pruner/handler.d.ts +20 -0
- package/dist/microvm/image-version-pruner/handler.js +116 -0
- package/dist/microvm/image-version-reporter/construct.d.ts +1 -1
- package/dist/microvm/image-version-reporter/construct.js +3 -3
- package/dist/microvm/image-version-reporter/handler.d.ts +2 -2
- package/dist/microvm/image-version-reporter/handler.js +9 -7
- package/dist/microvm/shapes.d.ts +10 -21
- package/dist/microvm/shapes.js +10 -17
- package/dist/waker-lambda/handler.js +3 -3
- package/package.json +3 -3
- package/dist/microvm-image-context/Dockerfile +0 -190
- package/dist/microvm-image-context/hook-server.js +0 -286
- package/dist/microvm-image-context/hooks/common.sh +0 -905
- package/dist/microvm-image-context/hooks/resume +0 -81
- package/dist/microvm-image-context/hooks/run +0 -95
- package/dist/microvm-image-context/hooks/suspend +0 -21
- package/dist/microvm-image-context/hooks/terminate +0 -36
|
@@ -29,15 +29,17 @@ var import_client_secrets_manager = require("@aws-sdk/client-secrets-manager");
|
|
|
29
29
|
var PHYSICAL_RESOURCE_ID = "evident-image-version-report";
|
|
30
30
|
var REPORT_TIMEOUT_MS = 5e3;
|
|
31
31
|
var secrets = new import_client_secrets_manager.SecretsManagerClient({});
|
|
32
|
-
async function
|
|
32
|
+
async function fetchControllerSigningSecret(secretArn, secretKey) {
|
|
33
33
|
const { SecretString } = await secrets.send(new import_client_secrets_manager.GetSecretValueCommand({ SecretId: secretArn }));
|
|
34
34
|
if (!SecretString) {
|
|
35
|
-
throw new Error(`
|
|
35
|
+
throw new Error(`controller signing secret ${secretArn} has no SecretString`);
|
|
36
36
|
}
|
|
37
37
|
const parsed = JSON.parse(SecretString);
|
|
38
38
|
const value = parsed !== null && typeof parsed === "object" ? parsed[secretKey] : void 0;
|
|
39
39
|
if (typeof value !== "string" || value === "") {
|
|
40
|
-
throw new Error(
|
|
40
|
+
throw new Error(
|
|
41
|
+
`controller signing secret ${secretArn} is missing a non-empty '${secretKey}' field`
|
|
42
|
+
);
|
|
41
43
|
}
|
|
42
44
|
return value;
|
|
43
45
|
}
|
|
@@ -63,7 +65,7 @@ function response() {
|
|
|
63
65
|
return { PhysicalResourceId: PHYSICAL_RESOURCE_ID };
|
|
64
66
|
}
|
|
65
67
|
var runtimeDependencies = {
|
|
66
|
-
getSecret:
|
|
68
|
+
getSecret: fetchControllerSigningSecret,
|
|
67
69
|
fetch: globalThis.fetch
|
|
68
70
|
};
|
|
69
71
|
async function handleImageVersionReport(event, getConfig, dependencies = runtimeDependencies) {
|
|
@@ -77,10 +79,15 @@ async function handleImageVersionReport(event, getConfig, dependencies = runtime
|
|
|
77
79
|
versions = readImageVersions(event.ResourceProperties?.imageVersions);
|
|
78
80
|
const config = getConfig();
|
|
79
81
|
runnerId = config.evidentRunnerId;
|
|
80
|
-
const secret = await dependencies.getSecret(
|
|
82
|
+
const secret = await dependencies.getSecret(
|
|
83
|
+
config.controllerSigningSecretArn,
|
|
84
|
+
config.controllerSigningSecretKey
|
|
85
|
+
);
|
|
81
86
|
const body = JSON.stringify({
|
|
82
87
|
type: "runner.microvm_image_versions_reported",
|
|
83
|
-
versions
|
|
88
|
+
versions,
|
|
89
|
+
// The API orders reports by this value because replacing an image restarts its version counter.
|
|
90
|
+
reporter_clock_ms: Date.now()
|
|
84
91
|
});
|
|
85
92
|
const signature = (0, import_node_crypto.createHmac)("sha256", secret).update(body).digest("hex");
|
|
86
93
|
const url = `${config.evidentApiUrl.replace(/\/+$/, "")}/v1/runners/${encodeURIComponent(
|
|
@@ -117,8 +124,8 @@ async function handleImageVersionReport(event, getConfig, dependencies = runtime
|
|
|
117
124
|
return response();
|
|
118
125
|
}
|
|
119
126
|
var handler = (event) => handleImageVersionReport(event, () => ({
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
controllerSigningSecretArn: requireEnv("CONTROLLER_SIGNING_SECRET_ARN"),
|
|
128
|
+
controllerSigningSecretKey: requireEnv("CONTROLLER_SIGNING_SECRET_KEY"),
|
|
122
129
|
evidentApiUrl: requireEnv("EVIDENT_API_URL"),
|
|
123
130
|
evidentRunnerId: requireEnv("EVIDENT_RUNNER_ID")
|
|
124
131
|
}));
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { EvidentWaker, type EvidentWakerProps } from './waker/construct';
|
|
|
3
3
|
export { EvidentMicrovmConstruct, type EvidentMicrovmConstructProps } from './microvm/construct';
|
|
4
4
|
export { MICROVM_SHAPES, validateShapes, type MicrovmShape } from './microvm/shapes';
|
|
5
5
|
export { MICROVM_MAX_RUN_SECONDS, HOOKS_PORT, HOOK_TIMEOUT_SECONDS, } from './microvm/constants';
|
|
6
|
-
export {
|
|
6
|
+
export { MICROVM_WORKSPACE_DIRECTORY, stageMicrovmBuildContext, type StageMicrovmBuildContextOptions, } from './microvm/image/stage-context';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.stageMicrovmBuildContext = exports.MICROVM_WORKSPACE_DIRECTORY = exports.HOOK_TIMEOUT_SECONDS = exports.HOOKS_PORT = exports.MICROVM_MAX_RUN_SECONDS = exports.validateShapes = exports.MICROVM_SHAPES = exports.EvidentMicrovmConstruct = exports.EvidentWaker = exports.EvidentScaleToZeroConstruct = void 0;
|
|
4
4
|
var evident_scale_to_zero_construct_1 = require("./evident-scale-to-zero-construct");
|
|
5
5
|
Object.defineProperty(exports, "EvidentScaleToZeroConstruct", { enumerable: true, get: function () { return evident_scale_to_zero_construct_1.EvidentScaleToZeroConstruct; } });
|
|
6
6
|
var construct_1 = require("./waker/construct");
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "MICROVM_MAX_RUN_SECONDS", { enumerable: true, ge
|
|
|
17
17
|
Object.defineProperty(exports, "HOOKS_PORT", { enumerable: true, get: function () { return constants_1.HOOKS_PORT; } });
|
|
18
18
|
Object.defineProperty(exports, "HOOK_TIMEOUT_SECONDS", { enumerable: true, get: function () { return constants_1.HOOK_TIMEOUT_SECONDS; } });
|
|
19
19
|
var stage_context_1 = require("./microvm/image/stage-context");
|
|
20
|
-
Object.defineProperty(exports, "
|
|
20
|
+
Object.defineProperty(exports, "MICROVM_WORKSPACE_DIRECTORY", { enumerable: true, get: function () { return stage_context_1.MICROVM_WORKSPACE_DIRECTORY; } });
|
|
21
|
+
Object.defineProperty(exports, "stageMicrovmBuildContext", { enumerable: true, get: function () { return stage_context_1.stageMicrovmBuildContext; } });
|
|
@@ -6,4 +6,4 @@ export declare const SUSPENDING_POLL_ATTEMPTS = 4;
|
|
|
6
6
|
export declare const SUSPENDING_POLL_INTERVAL_MS = 500;
|
|
7
7
|
export declare const MICROVM_MAX_RUN_SECONDS = 28800;
|
|
8
8
|
export declare const SESSION_CLEANUP_MAX_AGE = "24h";
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const CONTROLLER_SIGNING_SECRET_KEY = "CONTROLLER_SIGNING_SECRET";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// across them. The image template pins matching copies, guarded by
|
|
5
5
|
// `microvm/image/dockerfile.test.ts`.
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.CONTROLLER_SIGNING_SECRET_KEY = exports.SESSION_CLEANUP_MAX_AGE = exports.MICROVM_MAX_RUN_SECONDS = exports.SUSPENDING_POLL_INTERVAL_MS = exports.SUSPENDING_POLL_ATTEMPTS = exports.RUN_HOOK_PAYLOAD_MAX_BYTES = exports.HOOK_TIMEOUT_SECONDS = exports.HOOKS_DIR = exports.HOOKS_PORT = void 0;
|
|
8
8
|
// The port the image's hook server binds, baked into the published Dockerfile
|
|
9
9
|
// (`ENV HOOKS_PORT`) and passed to the construct as `hooksPort`. Exported from
|
|
10
10
|
// the package index because a consumer building the published image context
|
|
@@ -38,6 +38,9 @@ exports.MICROVM_MAX_RUN_SECONDS = 28800;
|
|
|
38
38
|
// The 24h window rather than 7d keeps the session database bounded at the growth
|
|
39
39
|
// rate observed in #537. The sweep runs on the default 1h interval.
|
|
40
40
|
exports.SESSION_CLEANUP_MAX_AGE = '24h';
|
|
41
|
-
// The JSON field inside the
|
|
42
|
-
// it and by whatever produces the secret; this is never the secret
|
|
43
|
-
|
|
41
|
+
// The JSON field inside the controller signing secret is shared by the Lambdas
|
|
42
|
+
// that name it and by whatever produces the secret; this is never the secret
|
|
43
|
+
// value. It is customer-facing and separate from persisted doorbell messages
|
|
44
|
+
// and telemetry. Changing the value silently stops an existing adopter's
|
|
45
|
+
// secret from being read.
|
|
46
|
+
exports.CONTROLLER_SIGNING_SECRET_KEY = 'CONTROLLER_SIGNING_SECRET';
|
|
@@ -4,12 +4,10 @@ import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
|
|
|
4
4
|
import { type MicrovmShape } from './shapes';
|
|
5
5
|
export interface EvidentMicrovmConstructProps {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* stays a pure function of its inputs instead of depending on how the
|
|
10
|
-
* ambient checkout was cloned.
|
|
7
|
+
* Directory containing the consumer's Dockerfile and every file it copies,
|
|
8
|
+
* typically the return value of `stageMicrovmBuildContext()`.
|
|
11
9
|
*/
|
|
12
|
-
readonly
|
|
10
|
+
readonly buildContextPath: string;
|
|
13
11
|
/**
|
|
14
12
|
* ARN of the Lambda-managed base MicroVM image, from
|
|
15
13
|
* `aws lambda-microvms list-managed-microvm-images`. A string, not a `CfnParameter`
|
|
@@ -33,14 +31,14 @@ export interface EvidentMicrovmConstructProps {
|
|
|
33
31
|
readonly shapes?: readonly MicrovmShape[];
|
|
34
32
|
/**
|
|
35
33
|
* The secret holding the shared HMAC key the controller verifies every
|
|
36
|
-
* doorbell against, under the field `
|
|
34
|
+
* doorbell against, under the field `CONTROLLER_SIGNING_SECRET`. Any Secrets Manager
|
|
37
35
|
* secret, however the caller manages it — this construct has no opinion on
|
|
38
36
|
* SOPS, KMS, or any other production mechanism. Required (not defaulted
|
|
39
37
|
* here): a default would need a scope of its own, and a caller-owned
|
|
40
38
|
* default keeps its own logical id — the caller builds one exactly once,
|
|
41
39
|
* in its own scope, and passes the result in either case.
|
|
42
40
|
*/
|
|
43
|
-
readonly
|
|
41
|
+
readonly controllerSigningSecret: secretsmanager.ISecret;
|
|
44
42
|
/**
|
|
45
43
|
* Optional runner secret whose JSON values are exported by `/run`. Omitting it
|
|
46
44
|
* leaves GitHub and MCP credentials unavailable to a generic consumer.
|
|
@@ -65,7 +63,7 @@ export interface EvidentMicrovmConstructProps {
|
|
|
65
63
|
* TCP port the image's hook server listens on, baked into both the image
|
|
66
64
|
* (`HOOKS_PORT` env var) and the `MicrovmImage`'s `hooks.port` — a mismatch
|
|
67
65
|
* means AWS probes a port nothing binds. Caller-supplied because the hook
|
|
68
|
-
* server is part of
|
|
66
|
+
* server is part of the base image, which this construct does not build.
|
|
69
67
|
*/
|
|
70
68
|
readonly hooksPort: number;
|
|
71
69
|
/**
|
|
@@ -93,6 +91,12 @@ export interface EvidentMicrovmConstructProps {
|
|
|
93
91
|
* throws at construction rather than silently disabling the reporter.
|
|
94
92
|
*/
|
|
95
93
|
readonly evidentRunnerId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Opts into bounding the per-image MicroVM version quota (L-F8BECE9C) for
|
|
96
|
+
* this deployment's images only, using the upstream engine defaults. Omitting
|
|
97
|
+
* this leaves the synthesised template byte-for-byte identical.
|
|
98
|
+
*/
|
|
99
|
+
readonly imageVersionPruning?: boolean;
|
|
96
100
|
}
|
|
97
101
|
/**
|
|
98
102
|
* The customer-account half of the per-session runner (#558): the MicroVM
|
|
@@ -37,12 +37,14 @@ exports.EvidentMicrovmConstruct = void 0;
|
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
const cdk = __importStar(require("aws-cdk-lib"));
|
|
39
39
|
const constructs_1 = require("constructs");
|
|
40
|
+
const iam = __importStar(require("aws-cdk-lib/aws-iam"));
|
|
40
41
|
const lambda = __importStar(require("aws-cdk-lib/aws-lambda"));
|
|
41
42
|
const s3 = __importStar(require("aws-cdk-lib/aws-s3"));
|
|
42
43
|
const lambda_microvm_cdk_1 = require("@evident-ai/lambda-microvm-cdk");
|
|
43
44
|
const constants_1 = require("./constants");
|
|
44
45
|
const shapes_1 = require("./shapes");
|
|
45
46
|
const construct_1 = require("./image-version-reporter/construct");
|
|
47
|
+
const construct_2 = require("./image-version-pruner/construct");
|
|
46
48
|
// Image hooks build the snapshot, so they get minutes where the runtime hooks
|
|
47
49
|
// get AWS's 60 s.
|
|
48
50
|
const IMAGE_HOOK_TIMEOUT_SECONDS = 600;
|
|
@@ -145,42 +147,31 @@ class EvidentMicrovmConstruct extends constructs_1.Construct {
|
|
|
145
147
|
lifecycleTimeout: cdk.Duration.seconds(props.hookTimeoutSeconds),
|
|
146
148
|
buildTimeout: cdk.Duration.seconds(IMAGE_HOOK_TIMEOUT_SECONDS),
|
|
147
149
|
};
|
|
148
|
-
// Built first
|
|
149
|
-
//
|
|
150
|
-
// shape
|
|
151
|
-
|
|
152
|
-
// and current logical id — zero CloudFormation churn on the live,
|
|
153
|
-
// hand-deployed stack (D3/D9). Every additional shape below borrows this
|
|
154
|
-
// role rather than getting one of its own, which is why `validateShapes`
|
|
155
|
-
// requires the default shape to be `shapes[0]`: it must exist before any
|
|
156
|
-
// other shape can reference its execution role.
|
|
157
|
-
const defaultImage = new lambda_microvm_cdk_1.MicrovmImage(this, defaultShape.constructId, {
|
|
150
|
+
// Built first without an `executionRole` prop, so every additional shape
|
|
151
|
+
// can borrow this image's execution role. `validateShapes` requires the
|
|
152
|
+
// default shape to be `shapes[0]` because that role must exist first.
|
|
153
|
+
const defaultImage = new lambda_microvm_cdk_1.MicrovmImage(this, defaultShape.name, {
|
|
158
154
|
imageName: defaultShape.imageName,
|
|
159
155
|
description: defaultShape.description,
|
|
160
156
|
// A local directory, so the zip is uploaded by `cdk deploy` itself and the
|
|
161
157
|
// image ARN is a stack reference rather than a deploy-time input.
|
|
162
|
-
source: props.
|
|
158
|
+
source: props.buildContextPath,
|
|
163
159
|
baseImageArn: props.baseImageArn,
|
|
164
160
|
baseImageVersion: props.baseImageVersion,
|
|
165
161
|
memoryMiB: defaultShape.memoryMiB,
|
|
166
162
|
environment: imageEnvironment,
|
|
167
163
|
hooks: imageHooks,
|
|
168
164
|
});
|
|
169
|
-
// WART
|
|
170
|
-
//
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
// intentional — see D3 in the plan. Do NOT "fix" this with
|
|
174
|
-
// `overrideLogicalId`: renaming the logical id IS the CloudFormation
|
|
175
|
-
// churn this design exists to avoid (a delete-and-recreate of the role a
|
|
176
|
-
// running MicroVM has live session credentials from). The wart is one
|
|
177
|
-
// comment; the override would undo the point of D3.
|
|
165
|
+
// WART: every additional shape shares `defaultImage.executionRole`, so the
|
|
166
|
+
// role's path under the default image reads as if it belongs to one shape
|
|
167
|
+
// even though it serves all of them. Keeping one role avoids replacing a
|
|
168
|
+
// role that running MicroVMs may still have credentials from.
|
|
178
169
|
const images = new Map([[defaultShape.name, defaultImage]]);
|
|
179
170
|
for (const shape of additionalShapes) {
|
|
180
|
-
images.set(shape.name, new lambda_microvm_cdk_1.MicrovmImage(this, shape.
|
|
171
|
+
images.set(shape.name, new lambda_microvm_cdk_1.MicrovmImage(this, shape.name, {
|
|
181
172
|
imageName: shape.imageName,
|
|
182
173
|
description: shape.description,
|
|
183
|
-
source: props.
|
|
174
|
+
source: props.buildContextPath,
|
|
184
175
|
baseImageArn: props.baseImageArn,
|
|
185
176
|
baseImageVersion: props.baseImageVersion,
|
|
186
177
|
memoryMiB: shape.memoryMiB,
|
|
@@ -189,13 +180,14 @@ class EvidentMicrovmConstruct extends constructs_1.Construct {
|
|
|
189
180
|
hooks: imageHooks,
|
|
190
181
|
}));
|
|
191
182
|
}
|
|
192
|
-
//
|
|
193
|
-
// the
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
183
|
+
// The execution role serves every image shape, so per-session state is scoped
|
|
184
|
+
// to the `runners/` root; vault credentials need only GetObject and PutObject.
|
|
185
|
+
durableState.grantReadWrite(defaultImage.executionRole, 'runners/*');
|
|
186
|
+
defaultImage.executionRole.addToPrincipalPolicy(new iam.PolicyStatement({
|
|
187
|
+
sid: 'ReadWriteCredentialVaultObjects',
|
|
188
|
+
actions: ['s3:GetObject', 's3:PutObject'],
|
|
189
|
+
resources: [durableState.arnForObjects('credential-vaults/*')],
|
|
190
|
+
}));
|
|
199
191
|
// The image receives only an ARN; `/run` reads the secret value at runtime.
|
|
200
192
|
props.runnerSecret?.grantRead(defaultImage.executionRole);
|
|
201
193
|
// The shape catalogue the controller resolves a doorbell's `shape` field
|
|
@@ -235,8 +227,8 @@ class EvidentMicrovmConstruct extends constructs_1.Construct {
|
|
|
235
227
|
// The ARN and field name, never the value: the controller reads it from
|
|
236
228
|
// Secrets Manager at runtime, so the key is not exposed to anyone with
|
|
237
229
|
// lambda:GetFunctionConfiguration.
|
|
238
|
-
|
|
239
|
-
|
|
230
|
+
CONTROLLER_SIGNING_SECRET_ARN: props.controllerSigningSecret.secretArn,
|
|
231
|
+
CONTROLLER_SIGNING_SECRET_KEY: constants_1.CONTROLLER_SIGNING_SECRET_KEY,
|
|
240
232
|
MICROVM_SHAPES: shapeCatalogueJson,
|
|
241
233
|
// The role every shape's MicroVM shares (D3) — still one role, still
|
|
242
234
|
// this same expression, now documented as shared rather than singular.
|
|
@@ -251,7 +243,7 @@ class EvidentMicrovmConstruct extends constructs_1.Construct {
|
|
|
251
243
|
// emit N near-identical policy statements and break the "exactly one
|
|
252
244
|
// statement granting X" guarantees this construct's test encodes.
|
|
253
245
|
defaultImage.grantRun(controller);
|
|
254
|
-
props.
|
|
246
|
+
props.controllerSigningSecret.grantRead(controller);
|
|
255
247
|
const functionUrl = controller.addFunctionUrl({
|
|
256
248
|
// HMAC verification of the doorbell body IS the auth, as for the ECS waker.
|
|
257
249
|
authType: lambda.FunctionUrlAuthType.NONE,
|
|
@@ -261,7 +253,7 @@ class EvidentMicrovmConstruct extends constructs_1.Construct {
|
|
|
261
253
|
// no custom resource — this branch must not run for them.
|
|
262
254
|
if (props.evidentApiUrl && props.evidentRunnerId) {
|
|
263
255
|
new construct_1.ImageVersionReporter(this, 'ImageVersionReporter', {
|
|
264
|
-
|
|
256
|
+
controllerSigningSecret: props.controllerSigningSecret,
|
|
265
257
|
evidentApiUrl: props.evidentApiUrl,
|
|
266
258
|
evidentRunnerId: props.evidentRunnerId,
|
|
267
259
|
imageVersions: Object.fromEntries(shapes.map((shape) => [shape.name, images.get(shape.name).latestActiveImageVersion])),
|
|
@@ -272,6 +264,23 @@ class EvidentMicrovmConstruct extends constructs_1.Construct {
|
|
|
272
264
|
buildTriggers: Object.fromEntries(shapes.map((shape) => [shape.name, images.get(shape.name).buildInputs])),
|
|
273
265
|
});
|
|
274
266
|
}
|
|
267
|
+
if (props.imageVersionPruning) {
|
|
268
|
+
const pruner = new construct_2.ImageVersionPruner(this, 'ImageVersionPruner', {
|
|
269
|
+
imageArns: shapes.map((shape) => (0, lambda_microvm_cdk_1.microvmImageArn)({
|
|
270
|
+
region: cdk.Stack.of(this).region,
|
|
271
|
+
accountId: cdk.Stack.of(this).account,
|
|
272
|
+
imageName: shape.imageName,
|
|
273
|
+
})),
|
|
274
|
+
buildTriggers: Object.fromEntries(shapes.map((shape) => {
|
|
275
|
+
const { buildRoleArn: _buildRoleArn, ...buildInputs } = images.get(shape.name).buildInputs;
|
|
276
|
+
return [shape.name, buildInputs];
|
|
277
|
+
})),
|
|
278
|
+
});
|
|
279
|
+
// Free a quota slot before the publish that consumes it.
|
|
280
|
+
for (const shape of shapes) {
|
|
281
|
+
images.get(shape.name).node.addDependency(pruner);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
275
284
|
this.functionUrl = functionUrl.url;
|
|
276
285
|
this.shapeCatalogueJson = shapeCatalogueJson;
|
|
277
286
|
this.durableStateBucket = durableState;
|
|
@@ -27,12 +27,12 @@ declare const WAKE_EVENT_TYPES: readonly ["agent.message_queued", "agent.wake_re
|
|
|
27
27
|
declare const SUSPEND_EVENT_TYPE = "runner.suspend_requested";
|
|
28
28
|
export declare const SHAPES_EVENT_TYPE = "runner.shapes_requested";
|
|
29
29
|
type WakeEventType = (typeof WAKE_EVENT_TYPES)[number];
|
|
30
|
-
type
|
|
30
|
+
type DoorbellRequestFields = {
|
|
31
31
|
runnerId: string;
|
|
32
32
|
occurredAt: string;
|
|
33
33
|
microvmId?: string;
|
|
34
34
|
};
|
|
35
|
-
export type
|
|
35
|
+
export type WakeDoorbellRequest = DoorbellRequestFields & {
|
|
36
36
|
type: WakeEventType;
|
|
37
37
|
runHookPayload: string;
|
|
38
38
|
/**
|
|
@@ -46,7 +46,7 @@ export type WakeDoorbell = DoorbellFields & {
|
|
|
46
46
|
*/
|
|
47
47
|
recreateOnOutdatedImage?: boolean;
|
|
48
48
|
};
|
|
49
|
-
export type
|
|
49
|
+
export type DoorbellRequest = WakeDoorbellRequest | (DoorbellRequestFields & {
|
|
50
50
|
type: typeof SUSPEND_EVENT_TYPE;
|
|
51
51
|
}) | {
|
|
52
52
|
type: typeof SHAPES_EVENT_TYPE;
|
|
@@ -67,12 +67,12 @@ export declare const DOORBELL_REJECTION: {
|
|
|
67
67
|
readonly runPayloadTooLarge: "run_payload_too_large";
|
|
68
68
|
};
|
|
69
69
|
export type DoorbellRejection = (typeof DOORBELL_REJECTION)[keyof typeof DOORBELL_REJECTION];
|
|
70
|
-
export type
|
|
70
|
+
export type ParsedDoorbellRequest = {
|
|
71
71
|
ok: true;
|
|
72
|
-
doorbell:
|
|
72
|
+
doorbell: DoorbellRequest;
|
|
73
73
|
} | {
|
|
74
74
|
ok: false;
|
|
75
75
|
reason: DoorbellRejection;
|
|
76
76
|
};
|
|
77
|
-
export declare function
|
|
77
|
+
export declare function parseDoorbellRequest(rawBody: string): ParsedDoorbellRequest;
|
|
78
78
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DOORBELL_REJECTION = exports.SHAPES_EVENT_TYPE = void 0;
|
|
4
|
-
exports.
|
|
4
|
+
exports.parseDoorbellRequest = parseDoorbellRequest;
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
/**
|
|
7
7
|
* The doorbell Evident POSTs to the controller's Function URL. `run_payload` is
|
|
@@ -52,7 +52,7 @@ function nonBlankString(value) {
|
|
|
52
52
|
function isWakeType(value) {
|
|
53
53
|
return WAKE_EVENT_TYPES.includes(value);
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function parseDoorbellRequest(rawBody) {
|
|
56
56
|
let body;
|
|
57
57
|
try {
|
|
58
58
|
body = JSON.parse(rawBody);
|
|
@@ -17,10 +17,10 @@ export type DoorbellResult = {
|
|
|
17
17
|
kind: ActionKind;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export declare function handleDoorbell({ rawBody, signatureHeader,
|
|
20
|
+
export declare function handleDoorbell({ rawBody, signatureHeader, controllerSigningSecret, shapes, microvm, sleep, random, }: {
|
|
21
21
|
rawBody: string;
|
|
22
22
|
signatureHeader: string | undefined;
|
|
23
|
-
|
|
23
|
+
controllerSigningSecret: string;
|
|
24
24
|
shapes: ShapeCatalogue;
|
|
25
25
|
microvm: MicrovmClient;
|
|
26
26
|
} & Timing): Promise<DoorbellResult>;
|