View, modify, and delete lifecycle policies - Amazon Elastic Compute Cloud

View, modify, and delete lifecycle policies

Use the following procedures to view, modify and delete existing lifecycle policies.

View lifecycle policies

Use one of the following procedures to view a lifecycle policy.

Console

To view a lifecycle policy

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Elastic Block Store, Lifecycle Manager.

  3. Select a lifecycle policy from the list. The Details tab displays information about the policy.

Command line

Use the get-lifecycle-policy command to display information about a lifecycle policy.

aws dlm get-lifecycle-policy --policy-id policy-0123456789abcdef0

The following is example output. It includes the information that you specified, plus metadata inserted by AWS.

{ "Policy":{ "Description": "My first policy", "DateCreated": "2018-05-15T00:16:21+0000", "State": "ENABLED", "ExecutionRoleArn": "arn:aws:iam::210774411744:role/AWSDataLifecycleManagerDefaultRole", "PolicyId": "policy-0123456789abcdef0", "DateModified": "2018-05-15T00:16:22+0000", "PolicyDetails": { "PolicyType":"EBS_SNAPSHOT_MANAGEMENT", "ResourceTypes": [ "VOLUME" ], "TargetTags": [ { "Value": "115", "Key": "costcenter" } ], "Schedules": [ { "TagsToAdd": [ { "Value": "myDailySnapshot", "Key": "type" } ], "RetainRule": { "Count": 5 }, "CopyTags": false, "CreateRule": { "Interval": 24, "IntervalUnit": "HOURS", "Times": [ "03:00" ] }, "Name": "DailySnapshots" } ] } } }

Modify lifecycle policies

Use one of the following procedures to modify a lifecycle policy.

Console

To modify a lifecycle policy

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Elastic Block Store, Lifecycle Manager.

  3. Select a lifecycle policy from the list.

  4. Choose Actions, Modify Lifecycle Policy.

  5. Modify the policy settings as needed. For example, you can modify the schedule, add or remove tags, or enable or disable the policy.

  6. Choose Update policy.

Command line

Use the update-lifecycle-policy command to modify the information in a lifecycle policy. To simplify the syntax, this example references a JSON file, policyDetailsUpdated.json, that includes the policy details.

aws dlm update-lifecycle-policy --state DISABLED --execution-role-arn arn:aws:iam::12345678910:role/AWSDataLifecycleManagerDefaultRole" --policy-details file://policyDetailsUpdated.json

The following is an example of the policyDetailsUpdated.json file.

{ "ResourceTypes":[ "VOLUME" ], "TargetTags":[ { "Key": "costcenter", "Value": "120" } ], "Schedules":[ { "Name": "DailySnapshots", "TagsToAdd": [ { "Key": "type", "Value": "myDailySnapshot" } ], "CreateRule": { "Interval": 12, "IntervalUnit": "HOURS", "Times": [ "15:00" ] }, "RetainRule": { "Count" :5 }, "CopyTags": false } ] }

To view the updated policy, use the get-lifecycle-policy command. You can see that the state, the value of the tag, the snapshot interval, and the snapshot start time were changed.

Delete lifecycle policies

Use one of the following procedures to delete a lifecycle policy.

Note

When you delete a lifecycle policy, the snapshots or AMIs created by that policy are not automatically deleted. If you no longer need the snapshots or AMIs, you must delete them manually.

Old console

To delete a lifecycle policy

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. In the navigation pane, choose Elastic Block Store, Lifecycle Manager.

  3. Select a lifecycle policy from the list.

  4. Choose Actions, Delete Lifecycle Policy.

  5. When prompted for confirmation, choose Delete Lifecycle Policy.

Command line

Use the delete-lifecycle-policy command to delete a lifecycle policy and free up the target tags specified in the policy for reuse.

Note

You can delete snapshots created only by Amazon Data Lifecycle Manager.

aws dlm delete-lifecycle-policy --policy-id policy-0123456789abcdef0

The Amazon Data Lifecycle Manager API Reference provides descriptions and syntax for each of the actions and data types for the Amazon Data Lifecycle Manager Query API.

Alternatively, you can use one of the AWS SDKs to access the API in a way that's tailored to the programming language or platform that you're using. For more information, see AWS SDKs.