| 1 | import type * as SSM from "@distilled.cloud/aws/ssm"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Parameter } from "./Parameter.ts"; |
| 5 | |
| 6 | export interface GetParametersByPathRequest extends Omit< |
| 7 | SSM.GetParametersByPathRequest, |
| 8 | "Path" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `ssm:GetParametersByPath`. |
| 13 | * |
| 14 | * Bind this operation to a `Parameter` with a hierarchical name (e.g. |
| 15 | * `/my-app/config`) to get a callable that reads every parameter stored |
| 16 | * *under* that name — the bound parameter acts as the subtree root. The |
| 17 | * binding grants `ssm:GetParametersByPath` on the parameter's ARN and its |
| 18 | * `/*` subtree wildcard, plus `kms:Decrypt` on the bound parameter's |
| 19 | * encryption key so `WithDecryption: true` works for `SecureString` children |
| 20 | * encrypted with the same key. |
| 21 | * ### Reading a Parameter Subtree |
| 22 | * **Example:** Read All Parameters Under a Path |
| 23 | * ```typescript |
| 24 | * const root = yield* SSM.Parameter("ConfigRoot", { |
| 25 | * name: "/my-app/config", |
| 26 | * value: "v1", |
| 27 | * }); |
| 28 | * const getByPath = yield* SSM.GetParametersByPath(root); |
| 29 | * |
| 30 | * // returns /my-app/config/db-url, /my-app/config/flags/beta, … |
| 31 | * const result = yield* getByPath({ Recursive: true }); |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface GetParametersByPath extends Binding.Service< |
| 37 | GetParametersByPath, |
| 38 | "AWS.SSM.GetParametersByPath", |
| 39 | <P extends Parameter>( |
| 40 | parameter: P, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request?: GetParametersByPathRequest, |
| 44 | ) => Effect.Effect< |
| 45 | SSM.GetParametersByPathResult, |
| 46 | SSM.GetParametersByPathError |
| 47 | > |
| 48 | > |
| 49 | > {} |
| 50 | export const GetParametersByPath = Binding.Service<GetParametersByPath>( |
| 51 | "AWS.SSM.GetParametersByPath", |
| 52 | ); |