| 1 | import type * as ECS from "@distilled.cloud/aws/ecs"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Cluster } from "./Cluster.ts"; |
| 5 | |
| 6 | export interface UpdateContainerInstancesStateRequest extends Omit< |
| 7 | ECS.UpdateContainerInstancesStateRequest, |
| 8 | "cluster" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `ecs:UpdateContainerInstancesState`. |
| 13 | * |
| 14 | * Bind this operation to a `Cluster` inside a function runtime to get a |
| 15 | * callable that transitions container instances between `ACTIVE` and |
| 16 | * `DRAINING` — the canonical building block of an Auto Scaling |
| 17 | * lifecycle-hook drain function that gracefully migrates tasks off an |
| 18 | * instance before it terminates. The cluster ARN is injected automatically |
| 19 | * and the host is granted `ecs:UpdateContainerInstancesState` on the |
| 20 | * cluster's container instances. |
| 21 | * ### Container Instances |
| 22 | * **Example:** Drain an Instance Before Termination |
| 23 | * ```typescript |
| 24 | * const updateContainerInstancesState = |
| 25 | * yield* AWS.ECS.UpdateContainerInstancesState(cluster); |
| 26 | * |
| 27 | * yield* updateContainerInstancesState({ |
| 28 | * containerInstances: [containerInstanceArn], |
| 29 | * status: "DRAINING", |
| 30 | * }); |
| 31 | * ``` |
| 32 | * |
| 33 | * @binding |
| 34 | */ |
| 35 | export interface UpdateContainerInstancesState extends Binding.Service< |
| 36 | UpdateContainerInstancesState, |
| 37 | "AWS.ECS.UpdateContainerInstancesState", |
| 38 | ( |
| 39 | cluster: Cluster, |
| 40 | ) => Effect.Effect< |
| 41 | ( |
| 42 | request: UpdateContainerInstancesStateRequest, |
| 43 | ) => Effect.Effect< |
| 44 | ECS.UpdateContainerInstancesStateResponse, |
| 45 | ECS.UpdateContainerInstancesStateError |
| 46 | > |
| 47 | > |
| 48 | > {} |
| 49 | export const UpdateContainerInstancesState = |
| 50 | Binding.Service<UpdateContainerInstancesState>( |
| 51 | "AWS.ECS.UpdateContainerInstancesState", |
| 52 | ); |