1import type * as microvms from "@distilled.cloud/aws/lambda-microvms";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { MicrovmImage } from "./MicrovmImage.ts";
5
6export interface RunMicrovmRequest extends Omit<
7 microvms.RunMicrovmRequest,
8 "imageIdentifier"
9> {}
10
11/**
12 * Runtime binding for `RunMicrovm`.
13 *
14 * Bind it to a {@link MicrovmImage} inside a Lambda Function to get a callable
15 * that launches a MicroVM from that image (the `imageIdentifier` is injected).
16 * The response carries the MicroVM `endpoint`; connect to it with an
17 * `X-aws-proxy-auth` token from {@link CreateAuthToken}.
18 *
19 * ### Running MicroVMs
20 * **Example:** Run a MicroVM
21 * ```typescript
22 * const runMicrovm = yield* AWS.Lambda.RunMicrovm(Sandbox);
23 *
24 * const vm = yield* runMicrovm({
25 * idlePolicy: {
26 * maxIdleDurationSeconds: 900,
27 * suspendedDurationSeconds: 300,
28 * autoResumeEnabled: true,
29 * },
30 * });
31 * ```
32 *
33 * @binding
34 */
35export interface RunMicrovm extends Binding.Service<
36 RunMicrovm,
37 "AWS.Lambda.RunMicrovm",
38 (
39 image: MicrovmImage,
40 ) => Effect.Effect<
41 (
42 request: RunMicrovmRequest,
43 ) => Effect.Effect<microvms.RunMicrovmResponse, microvms.RunMicrovmError>
44 >
45> {}
46export const RunMicrovm = Binding.Service<RunMicrovm>("AWS.Lambda.RunMicrovm");