@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 36 lines 1.25 KB
Raw
1 import * as IAM from "@alchemy.run/aws/IAM";
2 import * as Lambda from "@alchemy.run/aws/Lambda";
3 import * as Scheduler from "@alchemy.run/aws/Scheduler";
4 import * as Effect from "effect/Effect";
5 import * as HttpServerResponse from "effect/http/HttpServerResponse";
6 import path from "pathe";
7
8 const main = path.resolve(import.meta.dirname, "env-handler.ts");
9
10 // Minimal Lambda whose init binds CreateSchedule. The binding's deploy-time
11 // half resolves the AWS environment, which in a fresh run is the first
12 // resolution — it must not bind the deployer's config into this env (#1842).
13 export class SchedulerEnvFunction extends Lambda.Function<Lambda.Function>()(
14 "SchedulerEnvFunction",
15 ) {}
16
17 export default SchedulerEnvFunction.make(
18 { main },
19 Effect.gen(function* () {
20 const role = yield* IAM.Role("SchedulerEnvRole", {
21 assumeRolePolicyDocument: {
22 Version: "2012-10-17",
23 Statement: [
24 {
25 Effect: "Allow",
26 Principal: { Service: "scheduler.amazonaws.com" },
27 Action: ["sts:AssumeRole"],
28 },
29 ],
30 },
31 });
32 yield* Scheduler.CreateSchedule(role);
33
34 return { fetch: Effect.succeed(HttpServerResponse.text("ok")) };
35 }).pipe(Effect.provide(Scheduler.CreateScheduleHttp)),
36 );