| 1 | import type * as autoscaling from "@distilled.cloud/aws/auto-scaling"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { AutoScalingGroup } from "./AutoScalingGroup.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `SetInstanceProtection` request with `AutoScalingGroupName` injected from |
| 8 | * the bound {@link AutoScalingGroup}. |
| 9 | */ |
| 10 | export interface SetInstanceProtectionRequest extends Omit< |
| 11 | autoscaling.SetInstanceProtectionQuery, |
| 12 | "AutoScalingGroupName" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for the `SetInstanceProtection` operation (IAM action |
| 17 | * `autoscaling:SetInstanceProtection` scoped to the group ARN). |
| 18 | * |
| 19 | * Toggles scale-in protection on instances — e.g. a worker protects itself |
| 20 | * while it processes a long-running job, then removes protection when idle so |
| 21 | * the group may reclaim it. Provide the implementation with |
| 22 | * `Effect.provide(AWS.AutoScaling.SetInstanceProtectionHttp)`. |
| 23 | * ### Scale-In Protection |
| 24 | * **Example:** Protect a busy worker from scale-in |
| 25 | * ```typescript |
| 26 | * // init — bind the operation to the group |
| 27 | * const setInstanceProtection = |
| 28 | * yield* AWS.AutoScaling.SetInstanceProtection(group); |
| 29 | * |
| 30 | * // runtime — protect while working, release when idle |
| 31 | * yield* setInstanceProtection({ |
| 32 | * InstanceIds: [instanceId], |
| 33 | * ProtectedFromScaleIn: true, |
| 34 | * }); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface SetInstanceProtection extends Binding.Service< |
| 40 | SetInstanceProtection, |
| 41 | "AWS.AutoScaling.SetInstanceProtection", |
| 42 | ( |
| 43 | group: AutoScalingGroup, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request: SetInstanceProtectionRequest, |
| 47 | ) => Effect.Effect< |
| 48 | autoscaling.SetInstanceProtectionAnswer, |
| 49 | autoscaling.SetInstanceProtectionError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const SetInstanceProtection = Binding.Service<SetInstanceProtection>( |
| 55 | "AWS.AutoScaling.SetInstanceProtection", |
| 56 | ); |