| 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 | * `StopInstances` request with `InstanceIds` injected from the bound |
| 8 | * {@link Instance}. |
| 9 | */ |
| 10 | export interface StopInstanceRequest extends Omit< |
| 11 | ec2.StopInstancesRequest, |
| 12 | "InstanceId" | "InstanceIds" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for the `StopInstances` operation scoped to the bound |
| 17 | * {@link Instance} (IAM action `ec2:StopInstances` on the instance ARN). |
| 18 | * |
| 19 | * Stops the running instance — the other half of the scheduled |
| 20 | * start/stop-Lambda pattern that powers dev fleets off overnight. Pass |
| 21 | * `Hibernate: true` for hibernation-enabled instances. Provide the |
| 22 | * implementation with `Effect.provide(AWS.EC2.StopInstanceHttp)`. |
| 23 | * ### Instance Lifecycle Control |
| 24 | * **Example:** Stop the bound instance |
| 25 | * ```typescript |
| 26 | * // init — bind the operation to the instance |
| 27 | * const stopInstance = yield* AWS.EC2.StopInstance(instance); |
| 28 | * |
| 29 | * // runtime — power the instance off |
| 30 | * const result = yield* stopInstance(); |
| 31 | * console.log(result.StoppingInstances?.[0]?.CurrentState?.Name); |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface StopInstance extends Binding.Service< |
| 37 | StopInstance, |
| 38 | "AWS.EC2.StopInstance", |
| 39 | ( |
| 40 | instance: Instance, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request?: StopInstanceRequest, |
| 44 | ) => Effect.Effect<ec2.StopInstancesResult, ec2.StopInstancesError> |
| 45 | > |
| 46 | > {} |
| 47 | |
| 48 | export const StopInstance = Binding.Service<StopInstance>( |
| 49 | "AWS.EC2.StopInstance", |
| 50 | ); |