| 1 | import type * as ec2 from "@distilled.cloud/aws/ec2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Instance } from "./Instance.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `DescribeInstanceStatus` request with `InstanceIds` injected from the bound |
| 8 | * {@link Instance}. |
| 9 | */ |
| 10 | export interface DescribeInstanceStatusRequest extends Omit< |
| 11 | ec2.DescribeInstanceStatusRequest, |
| 12 | "InstanceId" | "InstanceIds" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for the `DescribeInstanceStatus` operation scoped to the |
| 17 | * bound {@link Instance} (IAM action `ec2:DescribeInstanceStatus`; |
| 18 | * `Describe*` actions do not support resource-level permissions, so the grant |
| 19 | * is on `*`). |
| 20 | * |
| 21 | * Reads the instance's system/instance status checks and scheduled events — |
| 22 | * e.g. a Lambda that alerts on failed reachability checks. Pass |
| 23 | * `IncludeAllInstances: true` to also see the status while the instance is |
| 24 | * stopped. Provide the implementation with |
| 25 | * `Effect.provide(AWS.EC2.DescribeInstanceStatusHttp)`. |
| 26 | * ### Observing Instances |
| 27 | * **Example:** Check the instance's status checks |
| 28 | * ```typescript |
| 29 | * // init — bind the operation to the instance |
| 30 | * const describeStatus = yield* AWS.EC2.DescribeInstanceStatus(instance); |
| 31 | * |
| 32 | * // runtime — read status checks (even while stopped) |
| 33 | * const result = yield* describeStatus({ IncludeAllInstances: true }); |
| 34 | * console.log(result.InstanceStatuses?.[0]?.InstanceStatus?.Status); |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface DescribeInstanceStatus extends Binding.Service< |
| 40 | DescribeInstanceStatus, |
| 41 | "AWS.EC2.DescribeInstanceStatus", |
| 42 | ( |
| 43 | instance: Instance, |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request?: DescribeInstanceStatusRequest, |
| 47 | ) => Effect.Effect< |
| 48 | ec2.DescribeInstanceStatusResult, |
| 49 | ec2.DescribeInstanceStatusError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const DescribeInstanceStatus = Binding.Service<DescribeInstanceStatus>( |
| 55 | "AWS.EC2.DescribeInstanceStatus", |
| 56 | ); |