@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, 04:45 UTC

main
ts 112 lines 3.72 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 * `StartInstanceRefresh` request with `AutoScalingGroupName` injected from
8 * the bound {@link AutoScalingGroup}.
9 */
10 export interface StartInstanceRefreshRequest extends Omit<
11 autoscaling.StartInstanceRefreshType,
12 "AutoScalingGroupName"
13 > {}
14
15 /**
16 * `CancelInstanceRefresh` request with `AutoScalingGroupName` injected from
17 * the bound {@link AutoScalingGroup}.
18 */
19 export interface CancelInstanceRefreshRequest extends Omit<
20 autoscaling.CancelInstanceRefreshType,
21 "AutoScalingGroupName"
22 > {}
23
24 /**
25 * `DescribeInstanceRefreshes` request with `AutoScalingGroupName` injected
26 * from the bound {@link AutoScalingGroup}.
27 */
28 export interface DescribeInstanceRefreshesRequest extends Omit<
29 autoscaling.DescribeInstanceRefreshesType,
30 "AutoScalingGroupName"
31 > {}
32
33 export interface InstanceRefreshClient {
34 /**
35 * Begin rolling the group's instances onto the current launch template (or
36 * the supplied `DesiredConfiguration`). Returns the refresh id to track.
37 */
38 start: (
39 request?: StartInstanceRefreshRequest,
40 ) => Effect.Effect<autoscaling.StartInstanceRefreshAnswer, autoscaling.StartInstanceRefreshError>;
41 /**
42 * Cancel the in-progress refresh. Instances already replaced are not rolled
43 * back — use `rollback` for that.
44 */
45 cancel: (
46 request?: CancelInstanceRefreshRequest,
47 ) => Effect.Effect<
48 autoscaling.CancelInstanceRefreshAnswer,
49 autoscaling.CancelInstanceRefreshError
50 >;
51 /**
52 * Roll the group back to the configuration it had before the in-progress
53 * refresh started.
54 */
55 rollback: () => Effect.Effect<
56 autoscaling.RollbackInstanceRefreshAnswer,
57 autoscaling.RollbackInstanceRefreshError
58 >;
59 /**
60 * Page through the group's instance refreshes (newest first), including
61 * per-refresh status and progress details.
62 */
63 describe: (
64 request?: DescribeInstanceRefreshesRequest,
65 ) => Effect.Effect<
66 autoscaling.DescribeInstanceRefreshesAnswer,
67 autoscaling.DescribeInstanceRefreshesError
68 >;
69 }
70
71 /**
72 * Runtime binding for the instance refresh operations — `StartInstanceRefresh`,
73 * `CancelInstanceRefresh`, `RollbackInstanceRefresh` (IAM actions scoped to
74 * the group ARN) and `DescribeInstanceRefreshes` (granted on `*`; EC2 Auto
75 * Scaling `Describe*` actions do not support resource-level permissions).
76 *
77 * Lets a deploy pipeline Lambda roll the fleet onto a new launch template
78 * version, watch progress, and cancel or roll back a bad deploy. Provide the
79 * implementation with `Effect.provide(AWS.AutoScaling.InstanceRefreshHttp)`.
80 * ### Rolling Deployments
81 * **Example:** Roll the fleet and watch progress
82 * ```typescript
83 * // init — bind the operations to the group
84 * const refresh = yield* AWS.AutoScaling.InstanceRefresh(group);
85 *
86 * // runtime — start a rolling replacement with auto-rollback
87 * const { InstanceRefreshId } = yield* refresh.start({
88 * Preferences: { MinHealthyPercentage: 90, AutoRollback: true },
89 * });
90 *
91 * // runtime — check on it
92 * const page = yield* refresh.describe({
93 * InstanceRefreshIds: [InstanceRefreshId!],
94 * });
95 * ```
96 *
97 * **Example:** Cancel a bad deploy
98 * ```typescript
99 * yield* refresh.cancel().pipe(
100 * Effect.catchTag("ActiveInstanceRefreshNotFoundFault", () => Effect.void),
101 * );
102 * ```
103 *
104 * @binding
105 */
106 export interface InstanceRefresh extends Binding.Service<
107 InstanceRefresh,
108 "AWS.AutoScaling.InstanceRefresh",
109 (group: AutoScalingGroup) => Effect.Effect<InstanceRefreshClient>
110 > {}
111
112 export const InstanceRefresh = Binding.Service<InstanceRefresh>("AWS.AutoScaling.InstanceRefresh");