Skip to content

Instance

Source: src/AWS/EC2/Instance.ts

An EC2 instance that can either act as a low-level compute primitive or run a bundled long-lived Effect program directly on the machine.

const instance = yield* AWS.EC2.Instance("AppInstance", {
imageId: AWS.EC2.amazonLinux2023(),
instanceType: "t3.micro",
subnetId: subnet.subnetId,
});
const api = yield* Effect.gen(function* () {
yield* Http.serve(
HttpServerResponse.json({ ok: true }),
);
return {
main: import.meta.url,
imageId: AWS.EC2.amazonLinux2023(),
instanceType: "t3.small",
subnetId: subnet.subnetId,
securityGroupIds: [securityGroup.groupId],
associatePublicIpAddress: true,
port: 3000,
};
}).pipe(
Effect.provide(AWS.EC2.HttpServer),
AWS.EC2.Instance("ApiInstance"),
);

main is bundled with rolldown at deploy time. Unused code is tree-shaken. effect, alchemy, and @distilled.cloud are marked pure so unused parts prune more aggressively. Your app is not marked pure.

Mark additional packages as pure

Only list packages with no top-level side effects.

{
main: import.meta.url,
build: {
pure: { packages: ["my-lib", "@my-scope/*"] },
},
}

Turn it off

{
main: import.meta.url,
build: { pure: false },
}