| 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 | * `SetInstanceHealth` request. The operation is instance-scoped — EC2 Auto |
| 8 | * Scaling resolves the instance's owning group for authorization, which the |
| 9 | * binding grants on the bound {@link AutoScalingGroup}'s ARN. |
| 10 | */ |
| 11 | export interface SetInstanceHealthRequest |
| 12 | extends autoscaling.SetInstanceHealthQuery {} |
| 13 | |
| 14 | /** |
| 15 | * Runtime binding for the `SetInstanceHealth` operation (IAM action |
| 16 | * `autoscaling:SetInstanceHealth` scoped to the group ARN). |
| 17 | * |
| 18 | * Reports an instance's health to EC2 Auto Scaling — the backbone of custom |
| 19 | * health checks: a watchdog Lambda (or the instance itself) flags an instance |
| 20 | * `Unhealthy` and the group replaces it. Provide the implementation with |
| 21 | * `Effect.provide(AWS.AutoScaling.SetInstanceHealthHttp)`. |
| 22 | * ### Custom Health Checks |
| 23 | * **Example:** Flag a failing instance for replacement |
| 24 | * ```typescript |
| 25 | * // init — bind the operation to the group |
| 26 | * const setInstanceHealth = yield* AWS.AutoScaling.SetInstanceHealth(group); |
| 27 | * |
| 28 | * // runtime — mark the instance unhealthy so the group replaces it |
| 29 | * yield* setInstanceHealth({ |
| 30 | * InstanceId: instanceId, |
| 31 | * HealthStatus: "Unhealthy", |
| 32 | * }); |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface SetInstanceHealth extends Binding.Service< |
| 38 | SetInstanceHealth, |
| 39 | "AWS.AutoScaling.SetInstanceHealth", |
| 40 | ( |
| 41 | group: AutoScalingGroup, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: SetInstanceHealthRequest, |
| 45 | ) => Effect.Effect< |
| 46 | autoscaling.SetInstanceHealthResponse, |
| 47 | autoscaling.SetInstanceHealthError |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | |
| 52 | export const SetInstanceHealth = Binding.Service<SetInstanceHealth>( |
| 53 | "AWS.AutoScaling.SetInstanceHealth", |
| 54 | ); |