| 1 | import * as docdb from "@distilled.cloud/aws/docdb"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import { makeDocDBClusterHttpBinding } from "./BindingHttp.ts"; |
| 4 | import { CreateDBClusterSnapshot } from "./CreateDBClusterSnapshot.ts"; |
| 5 | |
| 6 | export const CreateDBClusterSnapshotHttp = Layer.effect( |
| 7 | CreateDBClusterSnapshot, |
| 8 | makeDocDBClusterHttpBinding({ |
| 9 | tag: "AWS.DocDB.CreateDBClusterSnapshot", |
| 10 | operation: docdb.createDBClusterSnapshot, |
| 11 | actions: ["rds:CreateDBClusterSnapshot", "rds:AddTagsToResource"], |
| 12 | // Snapshot creation authorizes against BOTH the source cluster ARN and |
| 13 | // the target snapshot ARN — widen the grant to the account's DocumentDB |
| 14 | // cluster-snapshot space (`arn:…:rds:{region}:{account}:cluster-snapshot:*`). |
| 15 | extraResources: (clusterArn) => [ |
| 16 | `${clusterArn.split(":").slice(0, 5).join(":")}:cluster-snapshot:*`, |
| 17 | ], |
| 18 | }), |
| 19 | ); |