AWS Elemental MediaStore
User Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Adding an Object Lifecycle Policy to a Container

An object lifecycle policy lets you specify how long to store your objects in a container. You set an expiration date, and after the expiration date AWS Elemental MediaStore deletes the objects. To create the object lifecycle policy and attach it to a container, you use the AWS CLI. If the container already has an object lifecycle policy, the service replaces the existing policy with the new policy. It takes up to 20 minutes for the service to apply the new policy to the container.

For information about how to construct a lifecycle policy, see Components of an Object Lifecycle Policy.


For delete object rules (objects expire within days), there might be a slight lag between the expiration of an object and the deletion of the object. However, changes in billing happen as soon as the object expires. For example, if a lifecycle rule specifies 10 days_since_create, the account isn't billed for the object after the object is 10 days old, even if the object isn't deleted yet.

To create an object lifecycle policy (AWS CLI)

  1. Create a file that defines the object lifecycle policy:

    { "rules": [ { "definition": { "path": [ {"prefix": "Football/"}, {"prefix": "Baseball/"} ], "days_since_create": [ {"numeric": [">" , 28]} ] }, "action": "EXPIRE" }, { "definition": { "path": [ {"wildcard": "AwardsShow/index*.m3u8"} ], "seconds_since_create": [ {"numeric": [">" , 8]} ] }, "action": "EXPIRE" } ] }
  2. In the AWS CLI, use the put-lifecycle-policy command:

    aws mediastore put-lifecycle-policy --container-name LiveEvents --lifecycle-policy file://LiveEventsLifecyclePolicy.json

    This command has no return value. The service attaches the specified policy to the container.