| 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 | * `GetConsoleOutput` request with `InstanceId` injected from the bound |
| 8 | * {@link Instance}. |
| 9 | */ |
| 10 | export interface GetConsoleOutputRequest extends Omit< |
| 11 | ec2.GetConsoleOutputRequest, |
| 12 | "InstanceId" | "InstanceIds" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for the `GetConsoleOutput` operation scoped to the bound |
| 17 | * {@link Instance} (IAM action `ec2:GetConsoleOutput` on the instance ARN). |
| 18 | * |
| 19 | * Fetches the instance's serial console output (base64-encoded) — e.g. a |
| 20 | * diagnostics Lambda that captures boot logs when a host fails its health |
| 21 | * checks. Pass `Latest: true` for the most recent output on supported |
| 22 | * instance types. Provide the implementation with |
| 23 | * `Effect.provide(AWS.EC2.GetConsoleOutputHttp)`. |
| 24 | * ### Diagnostics |
| 25 | * **Example:** Capture the instance's console output |
| 26 | * ```typescript |
| 27 | * // init — bind the operation to the instance |
| 28 | * const getConsoleOutput = yield* AWS.EC2.GetConsoleOutput(instance); |
| 29 | * |
| 30 | * // runtime — fetch the (base64-encoded) boot log |
| 31 | * const result = yield* getConsoleOutput({ Latest: true }); |
| 32 | * const log = Buffer.from(result.Output ?? "", "base64").toString("utf8"); |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface GetConsoleOutput extends Binding.Service< |
| 38 | GetConsoleOutput, |
| 39 | "AWS.EC2.GetConsoleOutput", |
| 40 | ( |
| 41 | instance: Instance, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request?: GetConsoleOutputRequest, |
| 45 | ) => Effect.Effect<ec2.GetConsoleOutputResult, ec2.GetConsoleOutputError> |
| 46 | > |
| 47 | > {} |
| 48 | |
| 49 | export const GetConsoleOutput = Binding.Service<GetConsoleOutput>( |
| 50 | "AWS.EC2.GetConsoleOutput", |
| 51 | ); |