AWS
Host your Durable Objects in your AWS account, and the control plane runs on EC2 instances across availability zones, in a VPC of its own. Your pools run on Fargate or on EC2, and any Lambda, container or Worker calls the rooms by name.
import * as RivetAWS from "@alchemy.run/rivet/AWS";import * as Layer from "effect/Layer";
export const Cluster = RivetAWS.Ec2ControlPlane("Rivet");
export const Default = RivetAWS.EcsPool("Default").pipe(Layer.provide(Cluster));Install @alchemy.run/aws and finish AWS setup.
The control plane
Section titled “The control plane”You get three engines across availability zones in a VPC of their own. Each has an EBS disk, and they share an S3 bucket. An internal Application Load Balancer spreads calls across them, and CloudFront serves it over HTTPS at a cloudfront.net address, through a VPC origin, so the engines have no public address and you need no domain.
export const Cluster = RivetAWS.Ec2ControlPlane("Rivet", { instances: 3, instanceType: "t3.medium", diskSize: 20,});A disk outlives its instance, so a replaced instance picks up the same data.
On ECS
Section titled “On ECS”EcsControlPlane runs each engine as an ECS service on its own instance:
export const Cluster = RivetAWS.EcsControlPlane("Rivet", { cpu: 1024, memory: 2048 });It takes the same options as Ec2ControlPlane.
The pool
Section titled “The pool”EcsPool runs nodes on Fargate:
export const Default = RivetAWS.EcsPool("Default", { replicas: 2, cpu: 512, memory: 1024, architecture: "ARM64",}).pipe(Layer.provide(Cluster));Ec2Pool runs one EC2 instance per node:
export const Default = RivetAWS.Ec2Pool("Default", { instanceType: "t3.small" }).pipe( Layer.provide(Cluster),);Nodes run in the control plane’s VPC. With a control plane outside AWS, the pool creates a VPC of its own.
Rivet Services
Section titled “Rivet Services”ServicesPool runs Rivet Services on Fargate, in the control plane’s VPC:
export const Services = RivetAWS.ServicesPool("Services").pipe(Layer.provide(Cluster));Its image is copied into ECR when you deploy.
Call it from a Lambda
Section titled “Call it from a Lambda”export default class Api extends Lambda.Function<Api>()( "Api", { main: import.meta.url, functionUrl: true }, Effect.gen(function* () { const rooms = yield* Room; return { fetch: Effect.gen(function* () { const visitors = yield* rooms.getByName("lobby").join(); return yield* HttpServerResponse.json({ visitors }); }), }; }),) {}Every option, with its default, is in the reference: Ec2ControlPlane, EcsControlPlane, EcsPool, Ec2Pool and ServicesPool.