1import type * as kms from "@distilled.cloud/aws/kms";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5export interface GenerateRandomRequest extends kms.GenerateRandomRequest {}
6
7/**
8 * Runtime binding for `kms:GenerateRandom`.
9 *
10 * Not scoped to a key — KMS produces cryptographically secure random bytes
11 * from its FIPS 140-3 validated HSMs. The binding grants `kms:GenerateRandom`
12 * on `*` (the action does not support resource-level scoping).
13 *
14 * The random `Plaintext` in the response is wrapped in `Redacted` so it
15 * never leaks into logs — unwrap with `Redacted.value(...)` at the point of
16 * use.
17 *
18 * ### Random Bytes
19 * **Example:** Generate 32 Random Bytes
20 * ```typescript
21 * import * as Redacted from "effect/Redacted";
22 *
23 * const generateRandom = yield* AWS.KMS.GenerateRandom();
24 *
25 * const { Plaintext } = yield* generateRandom({ NumberOfBytes: 32 });
26 * const bytes = Redacted.isRedacted(Plaintext)
27 * ? Redacted.value(Plaintext)
28 * : Plaintext;
29 * ```
30 *
31 * @binding
32 */
33export interface GenerateRandom extends Binding.Service<
34 GenerateRandom,
35 "AWS.KMS.GenerateRandom",
36 () => Effect.Effect<
37 (
38 request?: GenerateRandomRequest,
39 ) => Effect.Effect<kms.GenerateRandomResponse, kms.GenerateRandomError>
40 >
41> {}
42
43export const GenerateRandom = Binding.Service<GenerateRandom>(
44 "AWS.KMS.GenerateRandom",
45);