AWS::DLM::LifecyclePolicy
Specifies a lifecycle policy, which is used to automate operations on Amazon EBS resources.
The properties are required when you add a lifecycle policy and optional when you update a lifecycle policy.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::DLM::LifecyclePolicy", "Properties" : { "CopyTags" :
Boolean
, "CreateInterval" :Integer
, "CrossRegionCopyTargets" :Json
, "DefaultPolicy" :String
, "Description" :String
, "Exclusions" :Exclusions
, "ExecutionRoleArn" :String
, "ExtendDeletion" :Boolean
, "PolicyDetails" :PolicyDetails
, "RetainInterval" :Integer
, "State" :String
, "Tags" :[ Tag, ... ]
} }
YAML
Type: AWS::DLM::LifecyclePolicy Properties: CopyTags:
Boolean
CreateInterval:Integer
CrossRegionCopyTargets:Json
DefaultPolicy:String
Description:String
Exclusions:Exclusions
ExecutionRoleArn:String
ExtendDeletion:Boolean
PolicyDetails:PolicyDetails
RetainInterval:Integer
State:String
Tags:- Tag
Properties
-
[Default policies only] Indicates whether the policy should copy tags from the source resource to the snapshot or AMI. If you do not specify a value, the default is
false
.Default: false
Required: No
Type: Boolean
Update requires: No interruption
CreateInterval
-
[Default policies only] Specifies how often the policy should run and create snapshots or AMIs. The creation frequency can range from 1 to 7 days. If you do not specify a value, the default is 1.
Default: 1
Required: No
Type: Integer
Minimum:
1
Update requires: No interruption
CrossRegionCopyTargets
-
[Default policies only] Specifies destination Regions for snapshot or AMI copies. You can specify up to 3 destination Regions. If you do not want to create cross-Region copies, omit this parameter.
Required: No
Type: Json
Minimum:
0
Maximum:
3
Update requires: No interruption
DefaultPolicy
-
[Default policies only] Specify the type of default policy to create.
-
To create a default policy for EBS snapshots, that creates snapshots of all volumes in the Region that do not have recent backups, specify
VOLUME
. -
To create a default policy for EBS-backed AMIs, that creates EBS-backed AMIs from all instances in the Region that do not have recent backups, specify
INSTANCE
.
Required: No
Type: String
Allowed values:
VOLUME | INSTANCE
Update requires: No interruption
-
Description
-
A description of the lifecycle policy. The characters ^[0-9A-Za-z _-]+$ are supported.
Required: Conditional
Type: String
Pattern:
[0-9A-Za-z _-]+
Minimum:
0
Maximum:
500
Update requires: No interruption
Exclusions
-
[Default policies only] Specifies exclusion parameters for volumes or instances for which you do not want to create snapshots or AMIs. The policy will not create snapshots or AMIs for target resources that match any of the specified exclusion parameters.
Required: No
Type: Exclusions
Update requires: No interruption
ExecutionRoleArn
-
The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy.
Required: Conditional
Type: String
Pattern:
arn:aws(-[a-z]{1,3}){0,2}:iam::\d+:role/.*
Minimum:
0
Maximum:
2048
Update requires: No interruption
ExtendDeletion
-
[Default policies only] Defines the snapshot or AMI retention behavior for the policy if the source volume or instance is deleted, or if the policy enters the error, disabled, or deleted state.
By default (ExtendDeletion=false):
-
If a source resource is deleted, Amazon Data Lifecycle Manager will continue to delete previously created snapshots or AMIs, up to but not including the last one, based on the specified retention period. If you want Amazon Data Lifecycle Manager to delete all snapshots or AMIs, including the last one, specify
true
. -
If a policy enters the error, disabled, or deleted state, Amazon Data Lifecycle Manager stops deleting snapshots and AMIs. If you want Amazon Data Lifecycle Manager to continue deleting snapshots or AMIs, including the last one, if the policy enters one of these states, specify
true
.
If you enable extended deletion (ExtendDeletion=true), you override both default behaviors simultaneously.
If you do not specify a value, the default is
false
.Default: false
Required: No
Type: Boolean
Update requires: No interruption
-
PolicyDetails
-
The configuration details of the lifecycle policy.
Important
If you create a default policy, you can specify the request parameters either in the request body, or in the PolicyDetails request structure, but not both.
Required: Conditional
Type: PolicyDetails
Update requires: No interruption
RetainInterval
-
[Default policies only] Specifies how long the policy should retain snapshots or AMIs before deleting them. The retention period can range from 2 to 14 days, but it must be greater than the creation frequency to ensure that the policy retains at least 1 snapshot or AMI at any given time. If you do not specify a value, the default is 7.
Default: 7
Required: No
Type: Integer
Minimum:
1
Update requires: No interruption
State
-
The activation state of the lifecycle policy.
Required: Conditional
Type: String
Allowed values:
ENABLED | DISABLED | ERROR
Update requires: No interruption
-
The tags to apply to the lifecycle policy during creation.
Required: No
Type: Array of Tag
Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the ID of the lifecycle policy.
For more information about using the Ref
function, see Ref
.
Fn::GetAtt
The Fn::GetAtt
intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt
intrinsic function, see Fn::GetAtt
.
Arn
-
The Amazon Resource Name (ARN) of the lifecycle policy.
Examples
Creating a Lifecycle Policy
The following example demonstrates how to create a basic snapshot lifecycle policy with a cross-Region copy rule.
JSON
{ "Description": "Basic LifecyclePolicy", "Resources": { "BasicLifecyclePolicy": { "Type": "AWS::DLM::LifecyclePolicy", "Properties": { "Description": "Lifecycle Policy using CloudFormation", "State": "ENABLED", "ExecutionRoleArn": "arn:aws:iam::123456789012:role/service-role/AWSDataLifecycleManagerDefaultRole", "PolicyDetails": { "ResourceTypes": [ "VOLUME" ], "TargetTags": [{ "Key": "costcenter", "Value": "115" }], "Schedules": [{ "Name": "Daily Snapshots", "TagsToAdd": [{ "Key": "type", "Value": "DailySnapshot" }], "CreateRule": { "Interval": 12, "IntervalUnit": "HOURS", "Times": [ "13:00" ] }, "RetainRule": { "Count": 1 }, "CopyTags": true, "CrossRegionCopyRules": [{ "Encrypted": false, "Target": "us-east-1" }] }] } } } } }
YAML
Description: Basic LifecyclePolicy Resources: BasicLifecyclePolicy: Type: AWS::DLM::LifecyclePolicy Properties: Description: Lifecycle Policy using CloudFormation State: ENABLED ExecutionRoleArn: arn:aws:iam::123456789012:role/service-role/AWSDataLifecycleManagerDefaultRole PolicyDetails: ResourceTypes: - VOLUME TargetTags: - Key: costcenter Value: '115' Schedules: - Name: Daily Snapshots TagsToAdd: - Key: type Value: DailySnapshot CreateRule: Interval: 12 IntervalUnit: HOURS Times: - '13:00' RetainRule: Count: 1 CopyTags: true CrossRegionCopyRules: - Encrypted: false Target: us-east-1
See also
-
CreateLifecyclePolicy in the Amazon Data Lifecycle Manager API Reference
-
Automating the Amazon EBS Snapshot Lifecycle in the Amazon Elastic Compute Cloud User Guide