@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 605 lines 21.9 KB
Raw
1 import type { Credentials } from "@distilled.cloud/aws/Credentials";
2 import type * as microvms from "@distilled.cloud/aws/lambda-microvms";
3 import type { Region } from "@distilled.cloud/aws/Region";
4 import type * as Bundle from "alchemy/Bundle/Bundle";
5 import { Platform } from "alchemy/Platform";
6 import type { Main } from "alchemy/Platform";
7 import type { Resource } from "alchemy/Resource";
8 import type { ProcessContext } from "alchemy/Runtime/Process";
9 import * as Effect from "effect/Effect";
10 import type { PolicyStatement } from "../IAM/Policy.ts";
11 import type { Role } from "../IAM/Role.ts";
12 import type { Providers } from "../Providers.ts";
13 import { makeMicrovmRuntimeContext, MicrovmImageTypeId } from "./MicrovmRuntimeContext.ts";
14
15 /**
16 * The IAM permissions a build role needs: read the code artifact from the
17 * Assets bucket(s) and write build logs to CloudWatch. Used to auto-grant a
18 * {@link Role} passed as `buildRole`.
19 */
20 const buildRolePolicyStatements: PolicyStatement[] = [
21 {
22 Effect: "Allow",
23 Action: ["s3:GetObject"],
24 Resource: ["arn:aws:s3:::alchemy-assets-*-an/*"],
25 },
26 {
27 Effect: "Allow",
28 Action: ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
29 Resource: ["arn:aws:logs:*:*:log-group:/aws/lambda/microvms/*"],
30 },
31 ];
32
33 export { MicrovmImageTypeId } from "./MicrovmRuntimeContext.ts";
34
35 export interface MicrovmImageProps {
36 /**
37 * The name of the MicroVM image. Must be 1-64 characters of letters,
38 * numbers, hyphens, or underscores. If omitted, a unique name is generated.
39 * Changing the name replaces the image.
40 */
41 name?: string;
42
43 /**
44 * **Effectful mode.** Entrypoint file for an Effect-native HTTP server,
45 * typically `import.meta.filename`. Alchemy bundles it (with its bindings),
46 * generates a Dockerfile, zips the result, and uploads it as the
47 * `codeArtifact`.
48 */
49 main?: string;
50
51 /**
52 * **External mode.** A build-context directory containing your Dockerfile and
53 * the files it copies. Alchemy zips and uploads it; AWS runs your Dockerfile.
54 * @default "./"
55 */
56 context?: string;
57
58 /**
59 * The Dockerfile. In effectful mode this is an inline base string (defaults
60 * to `FROM public.ecr.aws/lambda/microvms:al2023-minimal`). In external mode
61 * it is a path relative to {@link context} (defaults to `<context>/Dockerfile`).
62 */
63 dockerfile?: string;
64
65 /**
66 * The port the in-VM HTTP server listens on (effectful mode).
67 * @default 8080
68 */
69 port?: number;
70
71 /**
72 * The JS runtime to bundle for (effectful mode).
73 * @default "node"
74 */
75 runtime?: "bun" | "node";
76
77 /**
78 * Extra module ids to leave external when bundling (effectful mode).
79 */
80 external?: string[];
81
82 /**
83 * Bundler configuration for {@link main} (effectful mode). Unused
84 * code is tree-shaken. `effect`, alchemy, and `@distilled.cloud` are
85 * marked pure so unused parts prune more aggressively. List extra
86 * packages with `pure.packages`, or disable with `pure: false`.
87 *
88 * The program is minified with `keepNames` by default. On the Node
89 * runtime a source map ships with it and stack traces map back to your
90 * source; Bun ignores external source maps, so its traces keep function
91 * names but point into the bundle. Set `output: { minify: false }` to
92 * ship readable code.
93 */
94 build?: Bundle.BundleConfig;
95
96 /**
97 * The base MicroVM image to build on top of — either its ARN or another
98 * {@link MicrovmImage} instance. If omitted, the latest AWS-managed `al2023`
99 * base is used (discover bases with {@link microvms.listManagedMicrovmImages}).
100 */
101 baseImage?: string | MicrovmImage;
102
103 /**
104 * The specific version of the base MicroVM image.
105 */
106 baseImageVersion?: string;
107
108 /**
109 * The IAM role Lambda assumes to build the image (read the code artifact,
110 * write build logs) — either its ARN or an {@link Role} instance. When you
111 * pass a `Role`, the required S3 (Assets bucket) and CloudWatch-logs
112 * permissions are granted to it automatically via a binding, so you don't
113 * have to write the inline policy yourself. Required for all builds.
114 */
115 buildRole?: string | Role;
116
117 /**
118 * **Prebuilt mode.** A code artifact (S3 zip path or ECR image URI) to use
119 * as-is, instead of bundling (`main`) or building a context (`context`).
120 */
121 codeArtifact?: microvms.CodeArtifact;
122
123 /**
124 * A description of the image version.
125 */
126 description?: string;
127
128 /**
129 * Logging configuration for the MicroVM runtime/build. Specify exactly one of
130 * `cloudWatch` or `disabled`.
131 */
132 logging?: microvms.Logging;
133
134 /**
135 * The names/ARNs of egress network connectors available to the MicroVM at
136 * runtime (see {@link NetworkConnector}).
137 */
138 egressNetworkConnectors?: string[];
139
140 /**
141 * The CPU configurations the image supports.
142 */
143 cpuConfigurations?: microvms.CpuConfiguration[];
144
145 /**
146 * The resource requirements (e.g. minimum memory) for the MicroVM.
147 */
148 resources?: microvms.Resources[];
149
150 /**
151 * Additional OS capabilities granted to the MicroVM runtime.
152 */
153 additionalOsCapabilities?: microvms.Capability[];
154
155 /**
156 * Lifecycle hook configuration for the MicroVM and its image.
157 */
158 hooks?: microvms.Hooks;
159
160 /**
161 * Environment variables set in the MicroVM runtime environment. Capability
162 * bindings (e.g. S3/DynamoDB clients) also contribute entries here during
163 * plan; all of them are written to the image's environment.
164 */
165 env?: Record<string, any>;
166
167 /**
168 * Tags to apply to the image.
169 */
170 tags?: Record<string, string>;
171
172 /**
173 * @internal Platform-managed: the bundled runtime entrypoint.
174 */
175 exports?: string[] | Record<string, any>;
176
177 /**
178 * @internal Platform-managed: signals a non-Effect-native (external) image.
179 */
180 isExternal?: boolean;
181 }
182
183 export interface MicrovmImage extends Resource<
184 "AWS.Lambda.MicrovmImage",
185 MicrovmImageProps,
186 {
187 /** The ARN of the MicroVM image. */
188 imageArn: string;
189 /** The name of the MicroVM image. */
190 name: string;
191 /** The current state of the image (e.g. `CREATED`, `CREATING`). */
192 state: microvms.MicrovmImageState;
193 /** The image version produced by the most recent build. */
194 imageVersion?: string;
195 /** The latest version that built successfully. */
196 latestActiveImageVersion?: string;
197 /** The latest version that failed to build, if any. */
198 latestFailedImageVersion?: string;
199 /** When the image was created (ISO 8601). */
200 createdAt?: string;
201 /** When the image was last updated (ISO 8601). */
202 updatedAt?: string;
203 /**
204 * The resolved code artifact and its build identity hash. `contentHash`
205 * covers only the bundled program / packaged context (no props), so a
206 * content-only edit is detectable at plan time before the props resolve.
207 */
208 codeArtifact?: { uri?: string; hash?: string; contentHash?: string };
209 },
210 {
211 env?: Record<string, any>;
212 policyStatements?: PolicyStatement[];
213 },
214 Providers
215 > {}
216
217 export type MicrovmImageServices = Credentials | Region;
218 export type MicrovmImageShape = Main<MicrovmImageServices>;
219
220 /**
221 * A Lambda **MicroVM image** — a Firecracker snapshot that boots a fully
222 * initialized application in milliseconds. The model is *image-then-launch*:
223 * you create an image once (this resource), then launch isolated, stateful
224 * MicroVM instances from it at runtime (one per end-user/session) with the
225 * {@link RunMicrovm} binding from a Lambda Function.
226 *
227 * ### How the build works <!-- api-prose -->
228 *
229 * The build runs **server-side on AWS** — there is no local Docker. You supply
230 * a *code artifact* (a zip of a Dockerfile + your code) and a *base image*
231 * (`baseImage`); AWS runs your Dockerfile on top of the base, initializes
232 * the app, and takes a Firecracker snapshot. The build is asynchronous: the
233 * provider uploads the artifact, calls `CreateMicrovmImage`/`UpdateMicrovmImage`,
234 * and polls until the image reaches `CREATED`/`UPDATED` (or surfaces the build
235 * failure). Build logs stream to CloudWatch at `/aws/lambda/microvms/<name>`.
236 *
237 * Alchemy produces the code artifact for you in three ways, selected by which
238 * prop you set (`main` → `context` → `codeArtifact.uri`):
239 *
240 * - **Effectful** (`main`): write the in-VM HTTP server in TypeScript as an
241 * Effect. Alchemy bundles it (with its capability bindings), generates a
242 * Dockerfile on the MicroVM base, zips both, and uploads to the Assets bucket.
243 * - **External** (`context`/`dockerfile`): bring your own Dockerfile + build
244 * context (any language). Alchemy zips the directory and uploads it.
245 * - **Prebuilt** (`codeArtifact.uri`): point at an existing S3 zip or ECR image
246 * URI; nothing is built or uploaded.
247 *
248 * Re-deploys only trigger a new build when the artifact's content hash or a
249 * build-affecting prop changes; otherwise the image is left untouched.
250 *
251 * ### Prerequisites <!-- api-prose -->
252 *
253 * - A **build role** (`buildRole`) Lambda assumes to read the code artifact and
254 * write build logs. Pass a {@link Role} instance and the required permissions
255 * are granted automatically — see the example below.
256 * - A **bootstrapped Assets bucket** (`alchemy provider aws bootstrap`) for effectful /
257 * external modes, which upload the artifact to S3.
258 * - The account must be **onboarded to the Lambda MicroVM preview**.
259 *
260 *
261 * ### Creating the Build Role
262 * Pass a bare {@link Role} as `buildRole` and the MicroVM image grants
263 * everything it needs via a binding: the trust policy (so Lambda can assume it)
264 * plus the S3 (Assets bucket) and CloudWatch-logs permissions (folded into an
265 * `alchemy-bindings` inline policy). You don't write any policy yourself.
266 * **Example:** Bare build role
267 * ```typescript
268 * const buildRole = yield* AWS.IAM.Role("MicrovmBuildRole", {});
269 *
270 * // Pass the role instance; trust + permissions are attached for you.
271 * const image = yield* AWS.Lambda.MicrovmImage("Sandbox", {
272 * main: import.meta.filename,
273 * buildRole,
274 * });
275 * ```
276 *
277 * ### Effectful MicroVMs
278 * Write the in-VM server in TypeScript. Alchemy bundles `main` and bakes it into
279 * the image; the server listens on `port` (default 8080), which becomes the
280 * MicroVM `endpoint`.
281 * **Example:** In-VM HTTP server (single file)
282 * ```typescript
283 * export default class Sandbox extends AWS.Lambda.MicrovmImage<Sandbox>()(
284 * "Sandbox",
285 * { main: import.meta.filename, buildRole },
286 * Effect.gen(function* () {
287 * return {
288 * fetch: Effect.gen(function* () {
289 * const request = yield* HttpServerRequest;
290 * return HttpServerResponse.text(`hello from ${request.url}`);
291 * }),
292 * };
293 * }),
294 * ) {}
295 * ```
296 *
297 * **Example:** With capability bindings and env vars
298 * ```typescript
299 * export default class Sandbox extends AWS.Lambda.MicrovmImage<Sandbox>()(
300 * "Sandbox",
301 * {
302 * main: import.meta.filename,
303 * buildRole,
304 * runtime: "bun",
305 * env: { LOG_LEVEL: "info" },
306 * },
307 * Effect.gen(function* () {
308 * // bindings are bundled into the image and resolved at runtime
309 * const getObject = yield* AWS.S3.GetObject(bucket);
310 * return {
311 * fetch: Effect.gen(function* () {
312 * const obj = yield* getObject({ key: "data.json" });
313 * return HttpServerResponse.json(yield* obj.json);
314 * }),
315 * };
316 * }).pipe(Effect.provide(AWS.S3.GetObjectHttp)),
317 * ) {}
318 * ```
319 *
320 * **Example:** Class + `.make()` (two files, for a Lambda orchestrator)
321 * When a Lambda Function imports the image to bind its instance operations, keep
322 * the class (a typed handle) and the `.make()` runtime in separate files so the
323 * orchestrator's bundle doesn't pull in the VM's runtime deps.
324 * ```typescript
325 * // sandbox.ts — imported by the orchestrator
326 * export class Sandbox extends AWS.Lambda.MicrovmImage<Sandbox>()("Sandbox") {}
327 *
328 * // sandbox.live.ts — provided on the Stack; bundled into the image.
329 * // Must be the `default` export: the bundler resolves the image entrypoint
330 * // from the code artifact's default export.
331 * export default Sandbox.make(
332 * { main: import.meta.filename, buildRole },
333 * Effect.gen(function* () {
334 * return { fetch: Effect.gen(function* () {
335 * return HttpServerResponse.text("ok");
336 * }) };
337 * }),
338 * );
339 * ```
340 *
341 * ### Tagged RPC
342 * Beyond (or instead of) a raw `fetch` handler, an image can expose a typed
343 * **RPC `Shape`** as the second type parameter. The in-VM runtime serves those
344 * methods over an `/__rpc__/*` protocol and falls through to `fetch` for every
345 * other request, so an image can offer BOTH a typed RPC surface and ordinary
346 * HTTP routes. A caller gets a fully-typed client with {@link connectMicrovm}:
347 * value methods `yield*` as `Effect`s, streaming methods pipe as `Stream`s.
348 * **Example:** Define a tagged-RPC image (RPC + fetch)
349 * ```typescript
350 * // sandbox.ts — the typed handle imported by the orchestrator Lambda
351 * export class Sandbox extends AWS.Lambda.MicrovmImage<
352 * Sandbox,
353 * { hello: (message: string) => Effect.Effect<string> }
354 * >()("Sandbox") {}
355 *
356 * // sandbox.live.ts — provided on the Stack; bundled into the image (default export)
357 * export default Sandbox.make(
358 * { main: import.meta.filename, buildRole },
359 * Effect.gen(function* () {
360 * return {
361 * // RPC method — reached with `connectMicrovm` below
362 * hello: (message: string) => Effect.succeed(`hello, ${message}!`),
363 * // raw HTTP route — reached with a plain HTTPS request to the endpoint
364 * fetch: Effect.gen(function* () {
365 * const request = yield* HttpServerRequest;
366 * const url = new URL(request.url, "http://microvm");
367 * return HttpServerResponse.json({ path: url.pathname });
368 * }),
369 * };
370 * }),
371 * );
372 * ```
373 *
374 * **Example:** Call the RPC method from a Lambda
375 * `connectMicrovm` builds the typed stub over an `HttpClient` (provide
376 * `FetchHttpClient.layer` for the request scope), pointing at the running
377 * MicroVM's `endpoint` and authenticating with the `authToken` headers.
378 * ```typescript
379 * const vm = yield* runMicrovm({});
380 * // ...wait until `vm.state` is RUNNING (poll `getMicrovm`)...
381 * const { authToken } = yield* createAuthToken({
382 * microvmIdentifier: vm.microvmId,
383 * expirationInMinutes: 5,
384 * allowedPorts: [{ port: 8080 }], // the in-VM server's port
385 * });
386 *
387 * const sandbox = yield* AWS.Lambda.connectMicrovm(Sandbox, {
388 * endpoint: vm.endpoint,
389 * authToken,
390 * });
391 * const reply = yield* sandbox.hello("world"); // "hello, world!"
392 * ```
393 *
394 * **Example:** Call the same MicroVM's `fetch` route directly
395 * For the raw HTTP path, send the auth token as request headers via
396 * {@link microvmAuthHeaders}.
397 * ```typescript
398 * const client = yield* HttpClient.HttpClient;
399 * const res = yield* client.get(`https://${vm.endpoint}/echo?message=hi`, {
400 * headers: AWS.Lambda.microvmAuthHeaders(authToken),
401 * });
402 * const body = yield* res.json;
403 * ```
404 *
405 * ### Bundling & Tree-shaking
406 * `main` is bundled with rolldown at deploy time. Unused code is
407 * tree-shaken. `effect`, alchemy, and `@distilled.cloud` are marked
408 * pure so unused parts prune more aggressively. Your app is not
409 * marked pure.
410 *
411 * **Example:** Mark additional packages as pure
412 * Only list packages with no top-level side effects.
413 * ```typescript
414 * {
415 * main: import.meta.url,
416 * build: {
417 * pure: { packages: ["my-lib", "@my-scope/*"] },
418 * },
419 * }
420 * ```
421 *
422 * **Example:** Turn it off
423 * ```typescript
424 * {
425 * main: import.meta.url,
426 * build: { pure: false },
427 * }
428 * ```
429 *
430 * ### External Images (your own Dockerfile)
431 * Bring a build context directory containing a Dockerfile (any language).
432 * Alchemy zips and uploads it; AWS runs your Dockerfile. Your Dockerfile should
433 * build on a MicroVM-compatible base (e.g.
434 * `FROM public.ecr.aws/lambda/microvms:al2023-minimal`).
435 * **Example:** Flask app from a Dockerfile
436 * ```typescript
437 * const image = yield* AWS.Lambda.MicrovmImage("Flask", {
438 * context: `${import.meta.dirname}/app`, // dir with Dockerfile + app.py
439 * buildRole,
440 * });
441 * ```
442 * **Example:** Custom Dockerfile path within the context
443 * ```typescript
444 * const image = yield* AWS.Lambda.MicrovmImage("Worker", {
445 * context: `${import.meta.dirname}/app`,
446 * dockerfile: "docker/worker.Dockerfile", // relative to `context`
447 * buildRole,
448 * });
449 * ```
450 *
451 * ### Prebuilt Artifacts
452 * Skip the build entirely and point at an artifact you already produced.
453 * **Example:** From an existing S3 zip
454 * ```typescript
455 * const image = yield* AWS.Lambda.MicrovmImage("Prebuilt", {
456 * codeArtifact: { uri: "s3://my-bucket/app.zip" }, // or an ECR image URI
457 * buildRole,
458 * });
459 * ```
460 *
461 * ### Sizing and Base Image
462 * `baseImage` defaults to the latest AWS-managed `al2023` base (discovered
463 * via `listManagedMicrovmImages`). Override it, and tune CPU/memory, explicitly.
464 * **Example:** Pin the base image and resources
465 * ```typescript
466 * const image = yield* AWS.Lambda.MicrovmImage("Sized", {
467 * main: import.meta.filename,
468 * buildRole,
469 * baseImage: "arn:aws:lambda:us-east-1:aws:microvm-image:al2023-1",
470 * cpuConfigurations: [{ architecture: "ARM_64" }],
471 * resources: [{ minimumMemoryInMiB: 2048 }],
472 * });
473 * ```
474 *
475 * ### Logging
476 * **Example:** Stream runtime + build logs to a custom CloudWatch group
477 * ```typescript
478 * const image = yield* AWS.Lambda.MicrovmImage("Logged", {
479 * main: import.meta.filename,
480 * buildRole,
481 * logging: { cloudWatch: { logGroup: "/aws/microvm/my-app" } },
482 * // or disable: logging: { disabled: {} }
483 * });
484 * ```
485 *
486 * ### VPC Egress
487 * Give the MicroVM a managed egress path into your VPC with a
488 * {@link NetworkConnector} (reference it by ARN).
489 * **Example:** Image-level egress connector
490 * ```typescript
491 * const egress = yield* AWS.Lambda.NetworkConnector("Egress", {
492 * subnetIds: [subnet.subnetId],
493 * securityGroupIds: [sg.groupId],
494 * operatorRole: operatorRole.roleArn,
495 * });
496 *
497 * const image = yield* AWS.Lambda.MicrovmImage("Connected", {
498 * main: import.meta.filename,
499 * buildRole,
500 * egressNetworkConnectors: [egress.networkConnectorArn],
501 * });
502 * ```
503 *
504 * ### Launching MicroVMs
505 * The image is just the template. Launch and drive instances from a Lambda
506 * Function using the per-operation bindings ({@link RunMicrovm},
507 * {@link GetMicrovm}, {@link CreateAuthToken}, {@link TerminateMicrovm}, …).
508 * Each binding's IAM policy is scoped to this image automatically.
509 * **Example:** Run a MicroVM, call its RPC, and tear it down
510 * Always terminate the MicroVM you launched — wrap the work in
511 * `Effect.ensuring` so a failure (or a client retry) never leaks a running
512 * MicroVM against your account's memory quota. Give the Function a generous
513 * `timeout` since it waits for the MicroVM to reach RUNNING in-line.
514 * ```typescript
515 * export default class Api extends AWS.Lambda.Function<Api>()(
516 * "Api",
517 * { main: import.meta.filename, functionUrl: true, timeout: Duration.seconds(120) },
518 * Effect.gen(function* () {
519 * const runMicrovm = yield* AWS.Lambda.RunMicrovm(Sandbox);
520 * const getMicrovm = yield* AWS.Lambda.GetMicrovm(Sandbox);
521 * const createAuthToken = yield* AWS.Lambda.CreateAuthToken(Sandbox);
522 * const terminateMicrovm = yield* AWS.Lambda.TerminateMicrovm(Sandbox);
523 * return {
524 * fetch: Effect.gen(function* () {
525 * const vm = yield* runMicrovm({
526 * idlePolicy: {
527 * maxIdleDurationSeconds: 900,
528 * suspendedDurationSeconds: 300,
529 * autoResumeEnabled: true,
530 * },
531 * });
532 * return yield* Effect.gen(function* () {
533 * // wait until the MicroVM is RUNNING before connecting
534 * yield* getMicrovm({ microvmIdentifier: vm.microvmId }).pipe(
535 * Effect.flatMap((m) =>
536 * m.state === "RUNNING"
537 * ? Effect.void
538 * : Effect.fail(new Error(`microvm ${m.state}`)),
539 * ),
540 * Effect.retry({ schedule: Schedule.spaced("2 seconds"), times: 30 }),
541 * );
542 * const { authToken } = yield* createAuthToken({
543 * microvmIdentifier: vm.microvmId,
544 * expirationInMinutes: 5,
545 * allowedPorts: [{ port: 8080 }],
546 * });
547 * const sandbox = yield* AWS.Lambda.connectMicrovm(Sandbox, {
548 * endpoint: vm.endpoint,
549 * authToken,
550 * });
551 * const reply = yield* sandbox.hello("world");
552 * return yield* HttpServerResponse.json({ reply });
553 * }).pipe(
554 * // terminate on success OR failure — never leak a running MicroVM
555 * Effect.ensuring(
556 * terminateMicrovm({ microvmIdentifier: vm.microvmId }).pipe(
557 * Effect.ignore,
558 * ),
559 * ),
560 * // the in-VM endpoint calls need an HttpClient for this scope
561 * Effect.provide(FetchHttpClient.layer),
562 * );
563 * }),
564 * };
565 * }).pipe(
566 * Effect.provide(
567 * Layer.mergeAll(
568 * AWS.Lambda.RunMicrovmHttp,
569 * AWS.Lambda.GetMicrovmHttp,
570 * AWS.Lambda.CreateAuthTokenHttp,
571 * AWS.Lambda.TerminateMicrovmHttp,
572 * ),
573 * ),
574 * ),
575 * ) {}
576 * ```
577 *
578 * @resource
579 */
580 export const MicrovmImage: Platform<
581 MicrovmImage,
582 MicrovmImageServices,
583 MicrovmImageShape,
584 ProcessContext
585 > = Platform(MicrovmImageTypeId, {
586 createRuntimeContext: makeMicrovmRuntimeContext,
587 // When `buildRole` is a Role instance, grant it the build permissions via a
588 // binding so the user doesn't have to author the inline policy.
589 onCreate: (_resource, props: MicrovmImageProps) =>
590 props.buildRole && typeof props.buildRole !== "string"
591 ? props.buildRole.bind`Allow(${_resource}, AWS.Lambda.MicrovmImage.build)`({
592 // Grant the build permissions...
593 policyStatements: buildRolePolicyStatements,
594 // ...and the trust statement, so a build role passed as a bare
595 // `Role` (no `assumeRolePolicyDocument`) can be assumed by Lambda.
596 assumeRolePolicyStatements: [
597 {
598 Effect: "Allow",
599 Principal: { Service: "lambda.amazonaws.com" },
600 Action: ["sts:AssumeRole"],
601 },
602 ],
603 })
604 : Effect.void,
605 });