sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ KMS/ DescribeKey.ts

import type * as kms from "@distilled.cloud/aws/kms";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";
import type { AliasName } from "./Alias.ts";
import type { Key } from "./Key.ts";

export interface DescribeKeyRequest extends Omit<kms.DescribeKeyRequest, "KeyId"> {}

/**
 * Runtime binding for `kms:DescribeKey`.
 *
 * Bind this operation to a KMS {@link Key} (or the `alias/...` name of a
 * pre-existing key) to get a callable that automatically injects the
 * `KeyId`. Useful at runtime to discover a key's state, spec, and supported
 * algorithms before choosing a cryptographic operation.
 *
 * ### Key Metadata
 * **Example:** Inspect the Bound Key
 * ```typescript
 * const describeKey = yield* AWS.KMS.DescribeKey(key);
 *
 * const { KeyMetadata } = yield* describeKey();
 * // KeyMetadata.KeyState, KeyMetadata.KeySpec, ...
 * ```
 *
 * @binding
 */
export interface DescribeKey extends Binding.Service<
  DescribeKey,
  "AWS.KMS.DescribeKey",
  (
    key: Key | AliasName,
  ) => Effect.Effect<
    (request?: DescribeKeyRequest) => Effect.Effect<kms.DescribeKeyResponse, kms.DescribeKeyError>
  >
> {}

export const DescribeKey = Binding.Service<DescribeKey>("AWS.KMS.DescribeKey");