| 1 | import type * as autoscaling from "@distilled.cloud/aws/auto-scaling"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { AutoScalingGroup } from "./AutoScalingGroup.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `ExecutePolicy` request with `AutoScalingGroupName` injected from the bound |
| 8 | * {@link AutoScalingGroup}. `PolicyName` accepts either the policy name or its |
| 9 | * ARN (e.g. `policy.policyArn` from a {@link ScalingPolicy}). |
| 10 | */ |
| 11 | export interface ExecutePolicyRequest extends Omit< |
| 12 | autoscaling.ExecutePolicyType, |
| 13 | "AutoScalingGroupName" |
| 14 | > {} |
| 15 | |
| 16 | /** |
| 17 | * Runtime binding for the `ExecutePolicy` operation (IAM action |
| 18 | * `autoscaling:ExecutePolicy` scoped to the group ARN). |
| 19 | * |
| 20 | * Executes a step or simple scaling policy on the bound group — useful for |
| 21 | * testing a policy's design or driving scaling from application logic. |
| 22 | * Target-tracking policies cannot be executed manually. Provide the |
| 23 | * implementation with `Effect.provide(AWS.AutoScaling.ExecutePolicyHttp)`. |
| 24 | * ### Manual Scaling |
| 25 | * **Example:** Execute a step scaling policy |
| 26 | * ```typescript |
| 27 | * // init — bind the operation to the group |
| 28 | * const executePolicy = yield* AWS.AutoScaling.ExecutePolicy(group); |
| 29 | * |
| 30 | * // runtime — trigger the policy with a synthetic metric breach |
| 31 | * yield* executePolicy({ |
| 32 | * PolicyName: "scale-out-on-cpu", |
| 33 | * MetricValue: 85, |
| 34 | * BreachThreshold: 80, |
| 35 | * }); |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface ExecutePolicy extends Binding.Service< |
| 41 | ExecutePolicy, |
| 42 | "AWS.AutoScaling.ExecutePolicy", |
| 43 | ( |
| 44 | group: AutoScalingGroup, |
| 45 | ) => Effect.Effect< |
| 46 | ( |
| 47 | request: ExecutePolicyRequest, |
| 48 | ) => Effect.Effect< |
| 49 | autoscaling.ExecutePolicyResponse, |
| 50 | autoscaling.ExecutePolicyError |
| 51 | > |
| 52 | > |
| 53 | > {} |
| 54 | |
| 55 | export const ExecutePolicy = Binding.Service<ExecutePolicy>( |
| 56 | "AWS.AutoScaling.ExecutePolicy", |
| 57 | ); |