lifecycle_policies
Creates, updates, deletes, gets or lists a lifecycle_policies resource.
Overview
| Name | lifecycle_policies |
| Type | Resource |
| Id | aws.dlm.lifecycle_policies |
Fields
The following fields are returned by SELECT queries:
- get_lifecycle_policy
- get_lifecycle_policies
| Name | Datatype | Description |
|---|---|---|
date_created | string (date-time) | The local date and time when the lifecycle policy was created. |
date_modified | string (date-time) | The local date and time when the lifecycle policy was last modified. |
default_policy | boolean | Indicates whether the policy is a default lifecycle policy or a custom lifecycle policy. true - the policy is a default policy. false - the policy is a custom policy. |
description | string | The description of the lifecycle policy. (pattern: <code>[0-9A-Za-z _-]+</code>) |
execution_role_arn | string | The Amazon Resource Name (ARN) of the IAM role used to run the operations specified by the lifecycle policy. (pattern: <code>arn:aws(-[a-z]{1,3}){0,2}:iam::\d+:role/.*</code>) |
policy_arn | string | The Amazon Resource Name (ARN) of the policy. (pattern: <code>^arn:aws(-[a-z]{1,3}){0,2}:dlm:[A-Za-z0-9_/.-]{0,63}:\d+:policy/[0-9A-Za-z_-]{1,128}$</code>) |
policy_details | object | Specifies the configuration of a lifecycle policy. |
policy_id | string | The identifier of the lifecycle policy. (pattern: <code>policy-[a-f0-9]+</code>) |
state | string | The activation state of the lifecycle policy. (ENABLED, DISABLED, ERROR) |
status_message | string | The description of the status. (pattern: <code>[\p{all}]*</code>) |
tags | object | The tags. |
| Name | Datatype | Description |
|---|---|---|
policies | array | Summary information about the lifecycle policies. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_lifecycle_policy | select | policy_id, region | Gets detailed information about the specified lifecycle policy. | |
get_lifecycle_policies | select | region | policyIds, state, resourceTypes, targetTags, tagsToAdd, defaultPolicyType | Gets summary information about all or the specified data lifecycle policies. To get complete information about a policy, use GetLifecyclePolicy. |
create_lifecycle_policy | insert | region, ExecutionRoleArn, Description, State | Creates an Amazon Data Lifecycle Manager lifecycle policy. Amazon Data Lifecycle Manager supports the following policy types: Custom EBS snapshot policy Custom EBS-backed AMI policy Cross-account copy event policy Default policy for EBS snapshots Default policy for EBS-backed AMIs For more information, see Default policies vs custom policies. 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. | |
update_lifecycle_policy | update | policy_id, region | Updates the specified lifecycle policy. For more information about updating a policy, see Modify lifecycle policies. | |
delete_lifecycle_policy | delete | policy_id, region | Deletes the specified lifecycle policy and halts the automated operations that the policy specified. For more information about deleting a policy, see Delete lifecycle policies. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
policy_id | string | The identifier of the lifecycle policy. |
region | string | AWS region (default: us-east-1) |
defaultPolicyType | string | [Default policies only] Specifies the type of default policy to get. Specify one of the following: VOLUME - To get only the default policy for EBS snapshots INSTANCE - To get only the default policy for EBS-backed AMIs ALL - To get all default policies |
policyIds | array | The identifiers of the data lifecycle policies. |
resourceTypes | array | The resource type. |
state | string | The activation state. |
tagsToAdd | array | The tags to add to objects created by the policy. Tags are strings in the format key=value. These user-defined tags are added in addition to the Amazon Web Services-added lifecycle tags. |
targetTags | array | The target tag for a policy. Tags are strings in the format key=value. |
SELECT examples
- get_lifecycle_policy
- get_lifecycle_policies
Gets detailed information about the specified lifecycle policy.
SELECT
date_created,
date_modified,
default_policy,
description,
execution_role_arn,
policy_arn,
policy_details,
policy_id,
state,
status_message,
tags
FROM aws.dlm.lifecycle_policies
WHERE policy_id = '{{ policy_id }}' -- required
AND region = '{{ region }}' -- required
;
Gets summary information about all or the specified data lifecycle policies. To get complete information about a policy, use GetLifecyclePolicy.
SELECT
policies
FROM aws.dlm.lifecycle_policies
WHERE region = '{{ region }}' -- required
AND policyIds = '{{ policyIds }}'
AND state = '{{ state }}'
AND resourceTypes = '{{ resourceTypes }}'
AND targetTags = '{{ targetTags }}'
AND tagsToAdd = '{{ tagsToAdd }}'
AND defaultPolicyType = '{{ defaultPolicyType }}'
;
INSERT examples
- create_lifecycle_policy
- Manifest
Creates an Amazon Data Lifecycle Manager lifecycle policy. Amazon Data Lifecycle Manager supports the following policy types: Custom EBS snapshot policy Custom EBS-backed AMI policy Cross-account copy event policy Default policy for EBS snapshots Default policy for EBS-backed AMIs For more information, see Default policies vs custom policies. 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.
INSERT INTO aws.dlm.lifecycle_policies (
ExecutionRoleArn,
Description,
State,
PolicyDetails,
Tags,
DefaultPolicy,
CreateInterval,
RetainInterval,
CopyTags,
ExtendDeletion,
CrossRegionCopyTargets,
Exclusions,
region
)
SELECT
'{{ ExecutionRoleArn }}' /* required */,
'{{ Description }}' /* required */,
'{{ State }}' /* required */,
'{{ PolicyDetails }}',
'{{ Tags }}',
'{{ DefaultPolicy }}',
{{ CreateInterval }},
{{ RetainInterval }},
{{ CopyTags }},
{{ ExtendDeletion }},
'{{ CrossRegionCopyTargets }}',
'{{ Exclusions }}',
'{{ region }}'
RETURNING
policy_id
;
# Description fields are for documentation purposes
- name: lifecycle_policies
props:
- name: region
value: "{{ region }}"
description: Required parameter for the lifecycle_policies resource.
- name: ExecutionRoleArn
value: "{{ ExecutionRoleArn }}"
- name: Description
value: "{{ Description }}"
- name: State
value: "{{ State }}"
valid_values: ['ENABLED', 'DISABLED']
- name: PolicyDetails
description: |
Specifies the configuration of a lifecycle policy.
value:
PolicyType: "{{ PolicyType }}"
ResourceTypes:
- "{{ ResourceTypes }}"
ResourceLocations:
- "{{ ResourceLocations }}"
TargetTags:
- Key: "{{ Key }}"
Value: "{{ Value }}"
Schedules:
- Name: "{{ Name }}"
CopyTags: {{ CopyTags }}
TagsToAdd: "{{ TagsToAdd }}"
VariableTags: "{{ VariableTags }}"
CreateRule:
Location: "{{ Location }}"
Interval: {{ Interval }}
IntervalUnit: "{{ IntervalUnit }}"
Times:
- "{{ Times }}"
CronExpression: "{{ CronExpression }}"
Scripts:
- Stages: "{{ Stages }}"
ExecutionHandlerService: "{{ ExecutionHandlerService }}"
ExecutionHandler: "{{ ExecutionHandler }}"
ExecuteOperationOnScriptFailure: {{ ExecuteOperationOnScriptFailure }}
ExecutionTimeout: {{ ExecutionTimeout }}
MaximumRetryCount: {{ MaximumRetryCount }}
RetainRule:
Count: {{ Count }}
Interval: {{ Interval }}
IntervalUnit: "{{ IntervalUnit }}"
FastRestoreRule:
Count: {{ Count }}
Interval: {{ Interval }}
IntervalUnit: "{{ IntervalUnit }}"
AvailabilityZones:
- "{{ AvailabilityZones }}"
AvailabilityZoneIds:
- "{{ AvailabilityZoneIds }}"
CrossRegionCopyRules: "{{ CrossRegionCopyRules }}"
ShareRules: "{{ ShareRules }}"
DeprecateRule:
Count: {{ Count }}
Interval: {{ Interval }}
IntervalUnit: "{{ IntervalUnit }}"
ArchiveRule:
RetainRule:
RetentionArchiveTier:
Count: {{ Count }}
Interval: {{ Interval }}
IntervalUnit: "{{ IntervalUnit }}"
Parameters:
ExcludeBootVolume: {{ ExcludeBootVolume }}
NoReboot: {{ NoReboot }}
ExcludeDataVolumeTags:
- Key: "{{ Key }}"
Value: "{{ Value }}"
EventSource:
Type: "{{ Type }}"
Parameters:
EventType: "{{ EventType }}"
SnapshotOwner:
- "{{ SnapshotOwner }}"
DescriptionRegex: "{{ DescriptionRegex }}"
Actions:
- Name: "{{ Name }}"
CrossRegionCopy: "{{ CrossRegionCopy }}"
PolicyLanguage: "{{ PolicyLanguage }}"
ResourceType: "{{ ResourceType }}"
CreateInterval: {{ CreateInterval }}
RetainInterval: {{ RetainInterval }}
CopyTags: {{ CopyTags }}
CrossRegionCopyTargets:
- TargetRegion: "{{ TargetRegion }}"
ExtendDeletion: {{ ExtendDeletion }}
Exclusions:
ExcludeBootVolumes: {{ ExcludeBootVolumes }}
ExcludeVolumeTypes:
- "{{ ExcludeVolumeTypes }}"
ExcludeTags:
- Key: "{{ Key }}"
Value: "{{ Value }}"
- name: Tags
value: "{{ Tags }}"
- name: DefaultPolicy
value: "{{ DefaultPolicy }}"
valid_values: ['VOLUME', 'INSTANCE']
- name: CreateInterval
value: {{ CreateInterval }}
- name: RetainInterval
value: {{ RetainInterval }}
- name: CopyTags
value: {{ CopyTags }}
- name: ExtendDeletion
value: {{ ExtendDeletion }}
- name: CrossRegionCopyTargets
value:
- TargetRegion: "{{ TargetRegion }}"
- name: Exclusions
description: |
[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.
value:
ExcludeBootVolumes: {{ ExcludeBootVolumes }}
ExcludeVolumeTypes:
- "{{ ExcludeVolumeTypes }}"
ExcludeTags:
- Key: "{{ Key }}"
Value: "{{ Value }}"
UPDATE examples
- update_lifecycle_policy
Updates the specified lifecycle policy. For more information about updating a policy, see Modify lifecycle policies.
UPDATE aws.dlm.lifecycle_policies
SET
ExecutionRoleArn = '{{ ExecutionRoleArn }}',
State = '{{ State }}',
Description = '{{ Description }}',
PolicyDetails = '{{ PolicyDetails }}',
CreateInterval = {{ CreateInterval }},
RetainInterval = {{ RetainInterval }},
CopyTags = {{ CopyTags }},
ExtendDeletion = {{ ExtendDeletion }},
CrossRegionCopyTargets = '{{ CrossRegionCopyTargets }}',
Exclusions = '{{ Exclusions }}'
WHERE
policy_id = '{{ policy_id }}' --required
AND region = '{{ region }}' --required;
DELETE examples
- delete_lifecycle_policy
Deletes the specified lifecycle policy and halts the automated operations that the policy specified. For more information about deleting a policy, see Delete lifecycle policies.
DELETE FROM aws.dlm.lifecycle_policies
WHERE policy_id = '{{ policy_id }}' --required
AND region = '{{ region }}' --required
;