AWS Amazon Data Lifecycle Manager Lifecycle Policy
This page shows how to write Terraform and CloudFormation for Amazon Data Lifecycle Manager Lifecycle Policy and write them securely.
aws_dlm_lifecycle_policy (Terraform)
The Lifecycle Policy in Amazon Data Lifecycle Manager can be configured in Terraform with the resource name aws_dlm_lifecycle_policy
. The following sections describe 5 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_dlm_lifecycle_policy" "valheim_hourly_dlm" {
description = "Valheim HourlyDLM"
execution_role_arn = var.dlm_iam
state = "ENABLED"
policy_details {
resource "aws_dlm_lifecycle_policy" "minecraft_hourly_dlm" {
description = "Minecraft HourlyDLM"
execution_role_arn = var.dlm_iam
state = "ENABLED"
policy_details {
resource "aws_dlm_lifecycle_policy" "delegate_admin_lifecycle_policy" {
description = "DLM lifecycle policy"
execution_role_arn = aws_iam_role.delegate_admin_ec2_role.arn
state = "ENABLED"
policy_details {
resource "aws_dlm_lifecycle_policy" "backup" {
depends_on = [aws_iam_role_policy.dlm]
description = var.dlm_description
execution_role_arn = aws_iam_role.dlm.arn
tags = var.dlm_tags
resource "aws_dlm_lifecycle_policy" "gitlab_data_snapshot_policy" {
description = "Gitlab Data Volume DLM lifecycle policy"
execution_role_arn = aws_iam_role.dlm_lifecycle_role.arn
state = "ENABLED"
policy_details {
Parameters
-
arn
optional computed - string -
description
required - string -
execution_role_arn
required - string -
id
optional computed - string -
state
optional - string -
tags
optional - map from string to string -
policy_details
list block-
resource_types
required - list of string -
target_tags
required - map from string to string -
schedule
list block-
copy_tags
optional computed - bool -
name
required - string -
tags_to_add
optional - map from string to string -
create_rule
list block-
interval
required - number -
interval_unit
optional - string -
times
optional computed - list of string
-
-
retain_rule
list block-
count
required - number
-
-
-
Explanation in Terraform Registry
Provides a Data Lifecycle Manager (DLM) lifecycle policy for managing snapshots.
AWS::DLM::LifecyclePolicy (CloudFormation)
The LifecyclePolicy in DLM can be configured in CloudFormation with the resource name AWS::DLM::LifecyclePolicy
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: "AWS::DLM::LifecyclePolicy"
Properties:
Description: "Data Lifecycle Manager Policy"
State: "ENABLED"
ExecutionRoleArn:
Fn::GetAtt:
Type: AWS::DLM::LifecyclePolicy
Properties:
Description: "EBS-Snapshot Buckup Cross-Region"
ExecutionRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/AWSDataLifecycleManagerDefaultRole"
PolicyDetails:
ResourceTypes:
Type: AWS::DLM::LifecyclePolicy
Properties:
Description: "EBS-Snapshot Buckup Cross-Region"
ExecutionRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/AWSDataLifecycleManagerDefaultRole"
PolicyDetails:
ResourceTypes:
Type: "AWS::DLM::LifecyclePolicy"
Properties:
Description: "Daily EBS Snapshot"
State: "ENABLED"
ExecutionRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/AWSDataLifecycleManagerDefaultRole"
PolicyDetails:
Type: "AWS::DLM::LifecyclePolicy"
Properties:
Description: "Daily EBS Snapshot"
State: "ENABLED"
ExecutionRoleArn: !Sub "arn:aws:iam::${AWS::AccountId}:role/AWSDataLifecycleManagerDefaultRole"
PolicyDetails:
"Type": "AWS::DLM::LifecyclePolicy",
"Properties": {
"Description": "Lifecycle Policy using CloudFormation",
"State": "ENABLED",
"ExecutionRoleArn": "arn:aws:iam::345003923266:role/service-role/AWSDataLifecycleManagerDefaultRole",
"PolicyDetails": {
"Type": "AWS::DLM::LifecyclePolicy",
"Properties": {
"Description": "7 days",
"ExecutionRoleArn": {"Fn::GetAtt" : ["EBSRole", "Arn"] },
"State": "ENABLED",
"PolicyDetails": {
"Type": "AWS::DLM::LifecyclePolicy",
"Properties": {
"Description": "7 days",
"ExecutionRoleArn": {
"Fn::GetAtt": [
"EBSRole",
"Type": "AWS::DLM::LifecyclePolicy",
"DependsOn": "MCEBS",
"Properties": {
"Description": "Minecraft server EBS lifecycle policy",
"State": "ENABLED",
"ExecutionRoleArn": "arn:aws:iam::019828616938:role/service-role/AWSDataLifecycleManagerDefaultRole",
"Type": "AWS::DLM::LifecyclePolicy",
"Properties": {
"Description": "Lifecycle Policy using CloudFormation",
"State": "ENABLED",
"ExecutionRoleArn": {"Fn::Sub":"arn:aws:iam::${WMAwsAccountId}:role/AWSDataLifecycleManagerDefaultRole"},
"PolicyDetails": {
Parameters
-
ExecutionRoleArn
optional - String -
Description
optional - String -
State
optional - String -
PolicyDetails
optional - PolicyDetails -
Tags
optional - List of Tag
Explanation in CloudFormation Registry
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.
Frequently asked questions
What is AWS Amazon Data Lifecycle Manager Lifecycle Policy?
AWS Amazon Data Lifecycle Manager Lifecycle Policy is a resource for Amazon Data Lifecycle Manager of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon Data Lifecycle Manager Lifecycle Policy?
For Terraform, the caycehouse/terraform-valheim-aws, caycehouse/terraform-minecraft-aws and sarab321/AWSDevops source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the mobious999/Cloudformation, syouheitakahashi/aws-cloudformation and syouheitakahashi/aws-cloudformation source code examples are useful. See the CloudFormation Example section for further details.