Skip to main content

lifecycle_policies

Creates, updates, deletes, gets or lists a lifecycle_policies resource.

Overview

Namelifecycle_policies
TypeResource
Idaws.dlm.lifecycle_policies

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
date_createdstring (date-time)The local date and time when the lifecycle policy was created.
date_modifiedstring (date-time)The local date and time when the lifecycle policy was last modified.
default_policybooleanIndicates 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.
descriptionstringThe description of the lifecycle policy. (pattern: <code>[0-9A-Za-z _-]+</code>)
execution_role_arnstringThe 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_arnstringThe 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_detailsobjectSpecifies the configuration of a lifecycle policy.
policy_idstringThe identifier of the lifecycle policy. (pattern: <code>policy-[a-f0-9]+</code>)
statestringThe activation state of the lifecycle policy. (ENABLED, DISABLED, ERROR)
status_messagestringThe description of the status. (pattern: <code>[\p{all}]*</code>)
tagsobjectThe tags.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_lifecycle_policyselectpolicy_id, regionGets detailed information about the specified lifecycle policy.
get_lifecycle_policiesselectregionpolicyIds, state, resourceTypes, targetTags, tagsToAdd, defaultPolicyTypeGets summary information about all or the specified data lifecycle policies. To get complete information about a policy, use GetLifecyclePolicy.
create_lifecycle_policyinsertregion, ExecutionRoleArn, Description, StateCreates 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_policyupdatepolicy_id, regionUpdates the specified lifecycle policy. For more information about updating a policy, see Modify lifecycle policies.
delete_lifecycle_policydeletepolicy_id, regionDeletes 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.

NameDatatypeDescription
policy_idstringThe identifier of the lifecycle policy.
regionstringAWS region (default: us-east-1)
defaultPolicyTypestring[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
policyIdsarrayThe identifiers of the data lifecycle policies.
resourceTypesarrayThe resource type.
statestringThe activation state.
tagsToAddarrayThe 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.
targetTagsarrayThe target tag for a policy. Tags are strings in the format key=value.

SELECT examples

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
;

INSERT examples

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
;

UPDATE examples

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

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
;