Rule
Source:
src/AWS/Rbin/Rule.ts
A Recycle Bin retention rule. Recycle Bin retains deleted EBS snapshots, EBS-backed AMIs, and EBS volumes for a configurable period so they can be recovered after accidental deletion.
Rules are either tag-level (retain only resources carrying specific
resource tags) or Region-level (retain every resource of the type in
the Region, optionally minus exclusion tags). Changing resourceType
replaces the rule; every other property updates in place.
Creating Retention Rules
Section titled “Creating Retention Rules”Tag-level rule for EBS snapshots
import * as Rbin from "alchemy/AWS/Rbin";
const rule = yield* Rbin.Rule("SnapshotRetention", { resourceType: "EBS_SNAPSHOT", retentionPeriod: "7 days", description: "Retain tagged snapshots for 7 days", resourceTags: [{ key: "team", value: "data" }],});Region-level rule for AMIs
const rule = yield* Rbin.Rule("AmiRetention", { resourceType: "EC2_IMAGE", retentionPeriod: "14 days", description: "Retain all deregistered AMIs in this Region",});Region-level rule with exclusion tags
const rule = yield* Rbin.Rule("SnapshotRetention", { resourceType: "EBS_SNAPSHOT", retentionPeriod: "30 days", excludeResourceTags: [{ key: "ephemeral", value: "true" }],});Locking
Section titled “Locking”A Region-level rule (without exclusion tags) can be locked so it cannot
be modified or deleted. Removing lockConfiguration unlocks the rule,
which stays protected in pending_unlock until the unlock delay expires.
const rule = yield* Rbin.Rule("LockedRetention", { resourceType: "EBS_SNAPSHOT", retentionPeriod: "30 days", lockConfiguration: { unlockDelay: "7 days" },});Tagging
Section titled “Tagging”const rule = yield* Rbin.Rule("SnapshotRetention", { resourceType: "EBS_SNAPSHOT", retentionPeriod: "7 days", resourceTags: [{ key: "team", value: "data" }], tags: { CostCenter: "storage" },});