| 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 | * `StartInstances` request with `InstanceIds` injected from the bound |
| 8 | * {@link Instance}. |
| 9 | */ |
| 10 | export interface StartInstanceRequest extends Omit< |
| 11 | ec2.StartInstancesRequest, |
| 12 | "InstanceId" | "InstanceIds" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for the `StartInstances` operation scoped to the bound |
| 17 | * {@link Instance} (IAM action `ec2:StartInstances` on the instance ARN). |
| 18 | * |
| 19 | * Starts the stopped instance — the classic scheduled Lambda that powers dev |
| 20 | * boxes on in the morning. Starting an already-running instance succeeds |
| 21 | * without effect. Provide the implementation with |
| 22 | * `Effect.provide(AWS.EC2.StartInstanceHttp)`. |
| 23 | * ### Instance Lifecycle Control |
| 24 | * **Example:** Start the bound instance |
| 25 | * ```typescript |
| 26 | * // init — bind the operation to the instance |
| 27 | * const startInstance = yield* AWS.EC2.StartInstance(instance); |
| 28 | * |
| 29 | * // runtime — power the instance on |
| 30 | * const result = yield* startInstance(); |
| 31 | * console.log(result.StartingInstances?.[0]?.CurrentState?.Name); |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface StartInstance extends Binding.Service< |
| 37 | StartInstance, |
| 38 | "AWS.EC2.StartInstance", |
| 39 | ( |
| 40 | instance: Instance, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request?: StartInstanceRequest, |
| 44 | ) => Effect.Effect<ec2.StartInstancesResult, ec2.StartInstancesError> |
| 45 | > |
| 46 | > {} |
| 47 | |
| 48 | export const StartInstance = Binding.Service<StartInstance>( |
| 49 | "AWS.EC2.StartInstance", |
| 50 | ); |