1import type * as acmpca from "@distilled.cloud/aws/acm-pca";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { CertificateAuthority } from "./CertificateAuthority.ts";
5
6export interface IssueCertificateRequest extends Omit<
7 acmpca.IssueCertificateRequest,
8 "CertificateAuthorityArn"
9> {}
10
11/**
12 * Runtime binding for `acm-pca:IssueCertificate`.
13 *
14 * Bind a {@link CertificateAuthority} inside a function runtime to sign
15 * certificate signing requests (CSRs) with the CA's private key. Returns
16 * the ARN of the issued certificate — retrieve the PEM with the
17 * {@link GetCertificate} binding (issuance is asynchronous, so poll while
18 * `RequestInProgressException` is observed). Provide
19 * `ACMPCA.IssueCertificateHttp` on the Function effect to implement the
20 * binding.
21 *
22 * ### Issuing Certificates
23 * **Example:** Sign a CSR
24 * ```typescript
25 * // init
26 * const issueCertificate = yield* ACMPCA.IssueCertificate(ca);
27 *
28 * // runtime
29 * const issued = yield* issueCertificate({
30 * Csr: new TextEncoder().encode(csrPem),
31 * SigningAlgorithm: "SHA256WITHRSA",
32 * Validity: { Type: "DAYS", Value: 7 },
33 * });
34 * // issued.CertificateArn
35 * ```
36 *
37 * @binding
38 */
39export interface IssueCertificate extends Binding.Service<
40 IssueCertificate,
41 "AWS.ACMPCA.IssueCertificate",
42 (
43 certificateAuthority: CertificateAuthority,
44 ) => Effect.Effect<
45 (
46 request: IssueCertificateRequest,
47 ) => Effect.Effect<
48 acmpca.IssueCertificateResponse,
49 acmpca.IssueCertificateError
50 >
51 >
52> {}
53
54export const IssueCertificate = Binding.Service<IssueCertificate>(
55 "AWS.ACMPCA.IssueCertificate",
56);