1import * as AWS from "@/AWS";
2import * as Alchemy from "@/index.ts";
3import * as Effect from "effect/Effect";
4import { fileURLToPath } from "node:url";
5
6/**
7 * External MicroVM stack: builds a user-provided Dockerfile + context
8 * server-side (no Effect bundling). The build role is created bare — the
9 * MicroVM image grants it the trust + build permissions via a binding.
10 */
11export default Alchemy.Stack(
12 "MicrovmExternalStack",
13 {
14 providers: AWS.providers(),
15 state: Alchemy.localState(),
16 },
17 Effect.gen(function* () {
18 const buildRole = yield* AWS.IAM.Role("ExternalMicrovmBuildRole", {});
19 const image = yield* AWS.Lambda.MicrovmImage("ExternalSandbox", {
20 context: fileURLToPath(new URL("./", import.meta.url)),
21 buildRole,
22 });
23 return {
24 imageArn: image.imageArn.as<string>(),
25 state: image.state.as<string>(),
26 };
27 }),
28);