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

main
ts 76 lines 2.4 KB
Raw
1 import type * as autoscaling from "@distilled.cloud/aws/auto-scaling";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { AutoScalingGroup } from "./AutoScalingGroup.ts";
5
6 /**
7 * `EnterStandby` request with `AutoScalingGroupName` injected from the bound
8 * {@link AutoScalingGroup}.
9 */
10 export interface EnterStandbyRequest extends Omit<
11 autoscaling.EnterStandbyQuery,
12 "AutoScalingGroupName"
13 > {}
14
15 /**
16 * `ExitStandby` request with `AutoScalingGroupName` injected from the bound
17 * {@link AutoScalingGroup}.
18 */
19 export interface ExitStandbyRequest extends Omit<
20 autoscaling.ExitStandbyQuery,
21 "AutoScalingGroupName"
22 > {}
23
24 export interface StandbyClient {
25 /**
26 * Move instances into `Standby` — they stay attached (and optionally keep
27 * counting toward desired capacity) but receive no load balancer traffic.
28 */
29 enter: (
30 request: EnterStandbyRequest,
31 ) => Effect.Effect<autoscaling.EnterStandbyAnswer, autoscaling.EnterStandbyError>;
32 /**
33 * Move standby instances back into service; the desired capacity is
34 * incremented accordingly.
35 */
36 exit: (
37 request: ExitStandbyRequest,
38 ) => Effect.Effect<autoscaling.ExitStandbyAnswer, autoscaling.ExitStandbyError>;
39 }
40
41 /**
42 * Runtime binding for the `EnterStandby` / `ExitStandby` operations (IAM
43 * actions `autoscaling:EnterStandby` and `autoscaling:ExitStandby` scoped to
44 * the group ARN).
45 *
46 * Temporarily pulls instances out of service — to debug a misbehaving
47 * instance, apply a patch, or drain it during maintenance — and puts them
48 * back afterwards. Provide the implementation with
49 * `Effect.provide(AWS.AutoScaling.StandbyHttp)`.
50 * ### Standby Maintenance
51 * **Example:** Pull an instance for maintenance, then return it
52 * ```typescript
53 * // init — bind the operations to the group
54 * const standby = yield* AWS.AutoScaling.Standby(group);
55 *
56 * // runtime — take the instance out of rotation
57 * yield* standby.enter({
58 * InstanceIds: [instanceId],
59 * ShouldDecrementDesiredCapacity: true,
60 * });
61 *
62 * // ... perform maintenance ...
63 *
64 * // runtime — put it back in service
65 * yield* standby.exit({ InstanceIds: [instanceId] });
66 * ```
67 *
68 * @binding
69 */
70 export interface Standby extends Binding.Service<
71 Standby,
72 "AWS.AutoScaling.Standby",
73 (group: AutoScalingGroup) => Effect.Effect<StandbyClient>
74 > {}
75
76 export const Standby = Binding.Service<Standby>("AWS.AutoScaling.Standby");