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,
instanceType: "t3.micro",
subnetId: subnet.subnetId,
});
const api = yield* Effect.gen(function* () {
yield* Http.serve(
HttpServerResponse.json({ ok: true }),
);
return {
main: import.meta.filename,
imageId,
instanceType: "t3.small",
subnetId: subnet.subnetId,
securityGroupIds: [securityGroup.groupId],
associatePublicIpAddress: true,
port: 3000,
};
}).pipe(
Effect.provide(AWS.EC2.HttpServer),
AWS.EC2.Instance("ApiInstance"),
);