| 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 | |
| 5 | /** |
| 6 | * Runtime binding for `secretsmanager:GetRandomPassword`. |
| 7 | * |
| 8 | * Account-level operation (no target secret): bind it with no arguments to |
| 9 | * get a callable that generates cryptographically strong random passwords — |
| 10 | * typically paired with `PutSecretValue` for rotation. Provide the |
| 11 | * implementation with |
| 12 | * `Effect.provide(AWS.SecretsManager.GetRandomPasswordHttp)`. |
| 13 | * ### Generating Passwords |
| 14 | * **Example:** Generate and Store a New Password |
| 15 | * ```typescript |
| 16 | * // init — account-level, no resource argument |
| 17 | * const getRandomPassword = yield* AWS.SecretsManager.GetRandomPassword(); |
| 18 | * const putSecretValue = yield* AWS.SecretsManager.PutSecretValue(secret); |
| 19 | * |
| 20 | * // runtime — generate, then rotate the secret to it |
| 21 | * const generated = yield* getRandomPassword({ |
| 22 | * PasswordLength: 32, |
| 23 | * ExcludePunctuation: true, |
| 24 | * }); |
| 25 | * yield* putSecretValue({ SecretString: generated.RandomPassword }); |
| 26 | * ``` |
| 27 | * |
| 28 | * @binding |
| 29 | */ |
| 30 | export interface GetRandomPassword extends Binding.Service< |
| 31 | GetRandomPassword, |
| 32 | "AWS.SecretsManager.GetRandomPassword", |
| 33 | () => Effect.Effect< |
| 34 | ( |
| 35 | request?: secretsmanager.GetRandomPasswordRequest, |
| 36 | ) => Effect.Effect< |
| 37 | secretsmanager.GetRandomPasswordResponse, |
| 38 | secretsmanager.GetRandomPasswordError |
| 39 | > |
| 40 | > |
| 41 | > {} |
| 42 | |
| 43 | export const GetRandomPassword = Binding.Service<GetRandomPassword>( |
| 44 | "AWS.SecretsManager.GetRandomPassword", |
| 45 | ); |