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, 04:45 UTC
| 1 | import * as autoscaling from "@distilled.cloud/aws/auto-scaling"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Layer from "effect/Layer"; |
| 4 | import * as AWSBindings from "../AWSBindings.ts"; |
| 5 | import type { AutoScalingGroup } from "./AutoScalingGroup.ts"; |
| 6 | import { |
| 7 | CompleteLifecycleAction, |
| 8 | type CompleteLifecycleActionRequest, |
| 9 | type RecordLifecycleActionHeartbeatRequest, |
| 10 | } from "./CompleteLifecycleAction.ts"; |
| 11 | |
| 12 | export const CompleteLifecycleActionHttp = Layer.effect( |
| 13 | CompleteLifecycleAction, |
| 14 | Effect.gen(function* () { |
| 15 | const bind = yield* AWSBindings.Bind; |
| 16 | const complete = yield* AWSBindings.withCredentials(autoscaling.completeLifecycleAction); |
| 17 | const heartbeat = yield* AWSBindings.withCredentials( |
| 18 | autoscaling.recordLifecycleActionHeartbeat, |
| 19 | ); |
| 20 | |
| 21 | return Effect.fn(function* (group: AutoScalingGroup) { |
| 22 | const AutoScalingGroupName = yield* group.autoScalingGroupName; |
| 23 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 24 | yield* bind`AWS.AutoScaling.CompleteLifecycleAction(${group})`({ |
| 25 | policyStatements: [ |
| 26 | { |
| 27 | Effect: "Allow", |
| 28 | Action: [ |
| 29 | "autoscaling:CompleteLifecycleAction", |
| 30 | "autoscaling:RecordLifecycleActionHeartbeat", |
| 31 | ], |
| 32 | Resource: [group.autoScalingGroupArn], |
| 33 | }, |
| 34 | ], |
| 35 | }); |
| 36 | } |
| 37 | return { |
| 38 | complete: Effect.fn(`AWS.AutoScaling.CompleteLifecycleAction(${group.LogicalId})`)( |
| 39 | function* (request: CompleteLifecycleActionRequest) { |
| 40 | return yield* complete({ |
| 41 | ...request, |
| 42 | AutoScalingGroupName: yield* AutoScalingGroupName, |
| 43 | }); |
| 44 | }, |
| 45 | ), |
| 46 | heartbeat: Effect.fn(`AWS.AutoScaling.RecordLifecycleActionHeartbeat(${group.LogicalId})`)( |
| 47 | function* (request: RecordLifecycleActionHeartbeatRequest) { |
| 48 | return yield* heartbeat({ |
| 49 | ...request, |
| 50 | AutoScalingGroupName: yield* AutoScalingGroupName, |
| 51 | }); |
| 52 | }, |
| 53 | ), |
| 54 | }; |
| 55 | }); |
| 56 | }), |
| 57 | ); |