| 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 | * Runtime binding for the `DescribeInstances` operation scoped to the bound |
| 8 | * {@link Instance} (IAM action `ec2:DescribeInstances`; `Describe*` actions |
| 9 | * do not support resource-level permissions, so the grant is on `*`). |
| 10 | * |
| 11 | * Returns the bound instance's live description — state, addresses, block |
| 12 | * device mappings — e.g. a Lambda that reports whether a dev box is running. |
| 13 | * Provide the implementation with |
| 14 | * `Effect.provide(AWS.EC2.DescribeInstanceHttp)`. |
| 15 | * ### Observing Instances |
| 16 | * **Example:** Read the bound instance's live state |
| 17 | * ```typescript |
| 18 | * // init — bind the operation to the instance |
| 19 | * const describeInstance = yield* AWS.EC2.DescribeInstance(instance); |
| 20 | * |
| 21 | * // runtime — read the live description |
| 22 | * const live = yield* describeInstance(); |
| 23 | * console.log(live?.State?.Name, live?.PrivateIpAddress); |
| 24 | * ``` |
| 25 | * |
| 26 | * @binding |
| 27 | */ |
| 28 | export interface DescribeInstance extends Binding.Service< |
| 29 | DescribeInstance, |
| 30 | "AWS.EC2.DescribeInstance", |
| 31 | ( |
| 32 | instance: Instance, |
| 33 | ) => Effect.Effect< |
| 34 | () => Effect.Effect<ec2.Instance | undefined, ec2.DescribeInstancesError> |
| 35 | > |
| 36 | > {} |
| 37 | |
| 38 | export const DescribeInstance = Binding.Service<DescribeInstance>( |
| 39 | "AWS.EC2.DescribeInstance", |
| 40 | ); |