@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 56 lines 1.79 KB
Raw
1 import type * as ECS from "@distilled.cloud/aws/ecs";
2 import * as Binding from "alchemy/Binding";
3 import type * as Duration from "effect/Duration";
4 import type * as Effect from "effect/Effect";
5 import type { Cluster } from "./Cluster.ts";
6
7 export interface UpdateTaskProtectionRequest extends Omit<
8 ECS.UpdateTaskProtectionRequest,
9 "cluster" | "expiresInMinutes"
10 > {
11 /**
12 * How long the protection should last, e.g. `"20 minutes"` or
13 * `Duration.hours(1)`. Rounded to whole minutes on the wire
14 * (1 minute – 48 hours).
15 * @default "2 hours"
16 */
17 expiresIn?: Duration.Input;
18 }
19
20 /**
21 * Runtime binding for `ecs:UpdateTaskProtection`.
22 *
23 * Bind this operation to a `Cluster` inside a function runtime to get a
24 * callable that toggles scale-in protection on service-managed tasks in the
25 * bound cluster — the canonical pattern is a task protecting *itself* while
26 * it processes long-running work so deployments and scale-in don't terminate
27 * it. The cluster ARN is injected automatically and the host is granted
28 * `ecs:UpdateTaskProtection` on the cluster's tasks.
29 * ### Task Protection
30 * **Example:** Protect a Task While It Works
31 * ```typescript
32 * const updateTaskProtection = yield* AWS.ECS.UpdateTaskProtection(cluster);
33 *
34 * yield* updateTaskProtection({
35 * tasks: [taskArn],
36 * protectionEnabled: true,
37 * expiresIn: "30 minutes",
38 * });
39 * ```
40 *
41 * @binding
42 */
43 export interface UpdateTaskProtection extends Binding.Service<
44 UpdateTaskProtection,
45 "AWS.ECS.UpdateTaskProtection",
46 (
47 cluster: Cluster,
48 ) => Effect.Effect<
49 (
50 request: UpdateTaskProtectionRequest,
51 ) => Effect.Effect<ECS.UpdateTaskProtectionResponse, ECS.UpdateTaskProtectionError>
52 >
53 > {}
54 export const UpdateTaskProtection = Binding.Service<UpdateTaskProtection>(
55 "AWS.ECS.UpdateTaskProtection",
56 );