Amazon S3 lifecycle management
Cost of data (Objects) storage is important to consider when making decisions to use right storage technology. Amazon S3 Life cycle allows to configure a lifecycle for stored objects on S3, to optimize the cost. A Lifecycle configuration is a set of rules that define actions applied to a group of objects.
Types of S3 Lifecycle configuration Actions:
In Amazon S3 Lifecycle, there are two types of actions: transitions and expiration actions.
- Transition actions: It Allows to transit of the objects from one storage class to another storage class.
- Expiration actions: It allows you to delete expired objects automatically on your behalf.
Example of S3 lifecycle
- Application server, database logs are stored in s3 but logs may not require after a few weeks or months, in this case, you can delete the objects automatically by applying an expiration action.
- Frequency of access requirement of an organization’s documents (financial, media, employee data) Some documents are frequently accessed, but after a few days or months, they are infrequently accessed. After some time, organization may need to archive them as documents are not used anymore but must be retained for regulatory compliance, in this case, you can use transition action.
Configuration of S3 lifecycle
A lifecycle configuration is an XML file, Which contains a set of rules with predefined actions that you want to perform on stored objects during their lifetime.
Configuration XML example:
<LifecycleConfiguration> <Rule> //Rule: A lifecycle rule for individual objects in S3 bucket. <ID>cloudiofy-object-rule-1</ID> //ID: Unique identifier for the rule. <Expiration> //Expiration: Specifies the expiration for the lifecycle of the object <Days>90</Days> </Expiration> <Filter> //Filter: Filter (Prefix, Tag, logical AND for two or more predicates) is used to identify objects. <And> <Prefix>cloudiofy-logs</Prefix> //Prefix: Prefix identifying one or more objects to which the rule applies <Tag> //Tag: Tag for set the rules to apply <Key>environment</Key> <Value>production</Value> </Tag> <Tag> <Key>data-storage-type</Key> <Value>application-logs</Value> </Tag> </And> </Filter> <Status>Enabled</Status> //Status: If status 'Enabled', the rule is currently being applied. </Rule> </LifecycleConfiguration>
Read More – Examples of S3 Lifecycle