1import type * as backup from "@distilled.cloud/aws/backup";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Role } from "../IAM/Role.ts";
5import type { BackupVault } from "./BackupVault.ts";
6
7/**
8 * `StartBackupJob` request with `BackupVaultName` injected from the bound
9 * {@link BackupVault} and `IamRoleArn` defaulting to the bound backup role.
10 */
11export interface StartBackupJobRequest extends Omit<
12 backup.StartBackupJobInput,
13 "BackupVaultName" | "IamRoleArn"
14> {
15 /**
16 * IAM role AWS Backup assumes to create the backup.
17 * @default the backup role bound via `StartBackupJob(vault, role)`
18 */
19 IamRoleArn?: string;
20}
21
22/**
23 * Runtime binding for the `StartBackupJob` operation (IAM actions
24 * `backup:StartBackupJob` on the vault ARN + `iam:PassRole` on the backup
25 * role) — take an on-demand backup of any supported resource from a deployed
26 * Function.
27 *
28 * The binding is constructed with the target {@link BackupVault} and the
29 * **backup role** (the IAM role AWS Backup assumes to read the resource and
30 * write the recovery point; its trust policy must allow
31 * `backup.amazonaws.com`). Both are injected into every runtime request.
32 * Provide the implementation with
33 * `Effect.provide(AWS.Backup.StartBackupJobHttp)`.
34 * ### Starting Backups
35 * **Example:** On-Demand Backup Of A DynamoDB Table
36 * ```typescript
37 * // deploy time — bind the vault and the backup role
38 * const startBackupJob = yield* AWS.Backup.StartBackupJob(vault, backupRole);
39 *
40 * // runtime — snapshot the table before a risky migration
41 * const tableArn = yield* table.tableArn;
42 * const job = yield* startBackupJob({
43 * ResourceArn: tableArn,
44 * Lifecycle: { DeleteAfterDays: 7 },
45 * });
46 * yield* Effect.log(`backup job ${job.BackupJobId} started`);
47 * ```
48 *
49 * @binding
50 */
51export interface StartBackupJob extends Binding.Service<
52 StartBackupJob,
53 "AWS.Backup.StartBackupJob",
54 <R extends Role>(
55 vault: BackupVault,
56 backupRole: R,
57 ) => Effect.Effect<
58 (
59 request: StartBackupJobRequest,
60 ) => Effect.Effect<backup.StartBackupJobOutput, backup.StartBackupJobError>
61 >
62> {}
63export const StartBackupJob = Binding.Service<StartBackupJob>(
64 "AWS.Backup.StartBackupJob",
65);