| 1 | import * as secretsmanager from "@distilled.cloud/aws/secrets-manager"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Secret } from "./Secret.ts"; |
| 5 | |
| 6 | export interface BatchGetSecretValueRequest extends Omit< |
| 7 | secretsmanager.BatchGetSecretValueRequest, |
| 8 | "SecretIdList" | "Filters" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `secretsmanager:BatchGetSecretValue`. |
| 13 | * |
| 14 | * Bind this operation to a list of `Secret`s to get a callable that reads |
| 15 | * all of their current values in a single call — the batch counterpart of |
| 16 | * `GetSecretValue`. The bound secrets' ARNs are injected as the |
| 17 | * `SecretIdList` and each secret is granted `secretsmanager:GetSecretValue` |
| 18 | * (BatchGetSecretValue authorizes per-secret through GetSecretValue). |
| 19 | * Provide the implementation with |
| 20 | * `Effect.provide(AWS.SecretsManager.BatchGetSecretValueHttp)`. |
| 21 | * ### Reading Secret Values |
| 22 | * **Example:** Read Several Secrets at Once |
| 23 | * ```typescript |
| 24 | * // init — bind the operation to the secrets |
| 25 | * const batchGet = yield* AWS.SecretsManager.BatchGetSecretValue([ |
| 26 | * dbSecret, |
| 27 | * apiKeySecret, |
| 28 | * ]); |
| 29 | * |
| 30 | * // runtime — one call, every current value |
| 31 | * const result = yield* batchGet(); |
| 32 | * for (const entry of result.SecretValues ?? []) { |
| 33 | * console.log(entry.Name); |
| 34 | * } |
| 35 | * ``` |
| 36 | * |
| 37 | * @binding |
| 38 | */ |
| 39 | export interface BatchGetSecretValue extends Binding.Service< |
| 40 | BatchGetSecretValue, |
| 41 | "AWS.SecretsManager.BatchGetSecretValue", |
| 42 | ( |
| 43 | secrets: readonly Secret[], |
| 44 | ) => Effect.Effect< |
| 45 | ( |
| 46 | request?: BatchGetSecretValueRequest, |
| 47 | ) => Effect.Effect< |
| 48 | secretsmanager.BatchGetSecretValueResponse, |
| 49 | secretsmanager.BatchGetSecretValueError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const BatchGetSecretValue = Binding.Service<BatchGetSecretValue>( |
| 55 | "AWS.SecretsManager.BatchGetSecretValue", |
| 56 | ); |