Under enforcement a REST route no vendored model names runs unchecked, and DLM was among them: any caller could
create, read, update or delete a lifecycle policy and read or change its tags with no permission at all. DLM's model is
vendored now (regen_rest_routes.MODELS: dlm), so each request is checked as its operation's action, and dlm joins the
generated tables of request resources, passed roles and tags on create: the tag routes on the policy their path's ARN
names, the role CreateLifecyclePolicy and UpdateLifecyclePolicy pass in ExecutionRoleArn, and the tags a create
carries, which need dlm:TagResource.
The routes naming a policy by its PolicyId (GetLifecyclePolicy, UpdateLifecyclePolicy, DeleteLifecyclePolicy) are
checked on *, as the generated table reads them: a policy's ARN is policy/${ResourceName}, a name variable, which the
rule's compatible() keeps an id member from filling. CreateLifecyclePolicy's tags are checked on the policy the table
fills from DefaultPolicy, and on * when the request leaves it out.
DlmStoredResourceArns answers the tags DLM holds on the policy an ARN names, read in the ARN's account and Region by
the id it ends in without moving it and matched on the whole ARN, which an aws:ResourceTag condition reads. A namespace
the table reads is served on its tag routes only at the ARN its path encodes, so DlmIntegrationTest sends the ARN
encoded, as the SDKs do, and docs/services/dlm.md says so.
IamRestRouteEnforcementIntegrationTest checks that with no grant a policy's tags are refused, that a grant on one
policy's ARN reads them and refuses another's, that a deny on one policy's ARN refuses it and leaves another, that an
aws:ResourceTag condition reads a policy's tags, that GetLifecyclePolicy is checked on *, and that a create needs
iam:PassRole on its execution role and dlm:TagResource for the tags it carries.
2.8 KiB
Amazon Data Lifecycle Manager
Protocol: REST JSON
Endpoint: http://localhost:4566/policies (SigV4 service dlm)
Floci emulates the DLM management plane for EBS snapshot and AMI lifecycle policy configuration. Policies, nested policy details, and resource tags are persisted and isolated by account and region.
Supported Actions
| Action | Description |
|---|---|
CreateLifecyclePolicy |
Creates an EBS snapshot or AMI lifecycle policy configuration. |
GetLifecyclePolicy |
Returns one lifecycle policy and its nested details. |
GetLifecyclePolicies |
Lists lifecycle policies with the supported DLM filters. |
UpdateLifecyclePolicy |
Updates the supplied members of a lifecycle policy. |
DeleteLifecyclePolicy |
Deletes a lifecycle policy configuration. |
ListTagsForResource |
Lists the tags attached to a lifecycle policy. |
TagResource |
Adds or replaces tags on a lifecycle policy. |
UntagResource |
Removes selected tags from a lifecycle policy. |
GetLifecyclePolicies supports policy id, state, resource type, target-tag,
schedule-tag, and default-policy filters. UpdateLifecyclePolicy changes only the
members supplied by the caller and preserves the rest of the policy.
Policy timestamps use ISO 8601, as required by the DLM SDK model. Tags supplied on
create are returned by GetLifecyclePolicy and can also be managed with the resource
tagging actions, which take a policy's ARN at the path the model's /tags/{resourceArn}
gives it, URL-encoded as the SDKs send it; an ARN whose / is not encoded is refused
with BadRequestException ("Invalid resource ARN").
Not emulated
Floci stores DLM policy configuration but does not execute schedules. It does not
create EBS snapshots or AMIs, copy them across Regions, or enforce retention and
exclusion rules. The nested PolicyDetails document is retained so SDK and
infrastructure-as-code configuration can round-trip without claiming that backup
jobs have run.
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_DLM_ENABLED |
true |
Enable or disable the service |
Examples
export AWS_ENDPOINT_URL=http://localhost:4566
policy_id=$(aws dlm create-lifecycle-policy \
--execution-role-arn arn:aws:iam::000000000000:role/dlm \
--description daily \
--state ENABLED \
--policy-details '{"PolicyType":"EBS_SNAPSHOT_MANAGEMENT","ResourceTypes":["VOLUME"],"TargetTags":[{"Key":"backup","Value":"true"}],"Schedules":[{"Name":"daily","CreateRule":{"Interval":24,"IntervalUnit":"HOURS"},"RetainRule":{"Count":7}}]}' \
--query PolicyId \
--output text)
aws dlm get-lifecycle-policy --policy-id "$policy_id"
aws dlm get-lifecycle-policies --state ENABLED --resource-types VOLUME
aws dlm delete-lifecycle-policy --policy-id "$policy_id"