Skip to content

AWS.DLM reference

Source: src/AWS/DLM/GetLifecyclePolicies.ts

Runtime binding for dlm:GetLifecyclePolicies.

Enumerates the account’s Data Lifecycle Manager policies (optionally filtered by state, resource type, or target tags) — the building block of backup-coverage auditing: list every policy, flag the ones in ERROR, or verify a fleet’s tags are actually covered by an ENABLED policy. Provide the implementation with Effect.provide(AWS.DLM.GetLifecyclePoliciesHttp).

GetLifecyclePolicies: Monitoring Lifecycle Policies

Section titled “GetLifecyclePolicies: Monitoring Lifecycle Policies”
// init — account-level binding, no resource argument
const getLifecyclePolicies = yield* AWS.DLM.GetLifecyclePolicies();
// runtime
const { Policies } = yield* getLifecyclePolicies({ State: "ERROR" });
for (const policy of Policies ?? []) {
yield* Effect.logError(`DLM policy in ERROR: ${policy.PolicyId}`);
}

Source: src/AWS/DLM/GetLifecyclePolicy.ts

Runtime binding for dlm:GetLifecyclePolicy.

Reads the bound LifecyclePolicy’s full detail — state (including the observed-only ERROR), status message, execution role, and the complete policy document — so an ops function can audit backup coverage or alert on a policy that stopped running. The policy id is injected from the binding. Provide the implementation with Effect.provide(AWS.DLM.GetLifecyclePolicyHttp).

GetLifecyclePolicy: Monitoring Lifecycle Policies

Section titled “GetLifecyclePolicy: Monitoring Lifecycle Policies”
// init — bind the operation to the lifecycle policy
const getLifecyclePolicy = yield* AWS.DLM.GetLifecyclePolicy(policy);
// runtime
const { Policy } = yield* getLifecyclePolicy();
if (Policy?.State === "ERROR") {
yield* Effect.logError(`DLM policy failed: ${Policy.StatusMessage}`);
}

Source: src/AWS/DLM/LifecyclePolicy.ts

An Amazon Data Lifecycle Manager (DLM) lifecycle policy that automates the creation, retention, and deletion of EBS snapshots or EBS-backed AMIs.

LifecyclePolicy owns a custom EBS_SNAPSHOT_MANAGEMENT or IMAGE_MANAGEMENT policy. Volumes/instances are targeted by tags, and an execution role is created automatically unless an explicit executionRoleArn is given.

Daily EBS snapshots retained for a week

import * as DLM from "alchemy/AWS/DLM";
const policy = yield* DLM.LifecyclePolicy("DailySnapshots", {
policyDetails: {
resourceTypes: ["VOLUME"],
targetTags: { Backup: "daily" },
schedules: [
{
name: "Daily",
createRule: { interval: 24, intervalUnit: "HOURS", times: ["03:00"] },
retainRule: { count: 7 },
},
],
},
});

Cron-scheduled snapshots

const policy = yield* DLM.LifecyclePolicy("WeeklySnapshots", {
description: "Weekly volume snapshots",
policyDetails: {
resourceTypes: ["VOLUME"],
targetTags: { Backup: "weekly" },
schedules: [
{
name: "Weekly",
copyTags: true,
createRule: { cronExpression: "cron(0 4 ? * SUN *)" },
retainRule: { interval: 1, intervalUnit: "MONTHS" },
},
],
},
});
const amis = yield* DLM.LifecyclePolicy("NightlyAmis", {
policyDetails: {
policyType: "IMAGE_MANAGEMENT",
resourceTypes: ["INSTANCE"],
targetTags: { Backup: "ami" },
parameters: { noReboot: true },
schedules: [
{
name: "Nightly",
createRule: { interval: 24, intervalUnit: "HOURS", times: ["05:00"] },
retainRule: { count: 3 },
},
],
},
});
const role = yield* IAM.Role("DlmRole", {
assumeRolePolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: { Service: "dlm.amazonaws.com" },
Action: "sts:AssumeRole",
},
],
},
managedPolicyArns: [
"arn:aws:iam::aws:policy/service-role/AWSDataLifecycleManagerServiceRole",
],
});
const policy = yield* DLM.LifecyclePolicy("Snapshots", {
executionRoleArn: role.roleArn,
state: "DISABLED",
policyDetails: {
resourceTypes: ["VOLUME"],
targetTags: { Backup: "true" },
schedules: [
{
name: "Daily",
createRule: { interval: 24, intervalUnit: "HOURS" },
retainRule: { count: 2 },
},
],
},
});