AWS S3 Lifecycle Policies: Simple Storage Service Management

One of the most popular products from Amazon Web Service (AWS), is Simple Storage Service, popularly abbreviated as S3 . This service provides a durable, highly-available and inexpensive object storage for any kind of object — of any size. Behind S3’s durability and high-availability (HA), there are great engineering practices along with, redundancy and implementation of versioning that makes it very appealing as a web-scale storage service.
Everyone knows about Amazon S3, so discussing here wouldn’t serve us well. Rather, we are going to discuss how objects are stored, and how life-cyles of objects are maintained. I won’t dive into ASW S3 Lifecycle security in this post either. Security represents a crucial part of the developer’s responsibility is an important topic, so I suggest you read Stuart Scott’s post from this winter S3 Lifecycle Policies, Versioning & Encryption: AWS Security.
We have buckets in S3 and we store objects in them.
- How are these objects managed?
- How are the DR & HA achieved?
- How do objects underneath the storage layer behave when a PUT or DELETE operation is performed?
Let’s talk about S3 Objects and their lifecycle policies.
Amazon S3 achieves high availability by replicating data across multiple servers within Amazon’s data centers. If a PUT request is successful, your data is safely stored. However, information about the changes must replicate across Amazon S3. Also, S3 keeps multiple versions of the Object to achieve HA. Enabling or disabling versioning of one object within the bucket is optional. If you enable versioning, you can protect your objects from accidental deletion or being overwritten because you have the option of retrieving older versions of them.
Object versioning can be used in combination with Object Lifecycle Management, which allows you the option of customizing your data retention requirements while controlling your storage costs.
When you PUT an object in a versioning-enabled bucket, the noncurrent version is not overwritten. Rather, when a new version of a file or an object is PUT into a bucket that already contains an object with the same name, the original object remains in the bucket, and Amazon S3 generates a new version ID. Amazon S3 then adds the newer version to the bucket. This service is automatically performed by S3 so that, as a user, your only concern is enabling and disabling the versioning in the bucket.
Amazon S3 also provides resources for managing lifecycle by user need. For example, if you want to move less frequently accessed data to Glacier, or set a rule to delete the file (e.g. old log files of an application stored in a bucket) after a specified interval of time, you can easily automate the process. AWS allows the enabling of up-to 100 lifecycle rules for achieving control of your objects in S3 buckets.
Amazon S3 Lifecycle configurations are provided by means of XML. A typical configuration looks like this:
<LifecycleConfiguration> <Rule> <ID> cloudacademy-image-rule</ID> <Prefix>cloudacademyblogimg/</Prefix> <Status>Enabled</Status> <Transition> <Days>90</Days> <StorageClass>GLACIER</StorageClass> </Transition> <Expiration> <Days>365</Days> </Expiration> </Rule> </LifecycleConfiguration>
Here we have defined an S3 lifecycle configuration for objects in a bucket. We have images in a bucket stored in the folder named cloudacademyblogimg and we want to move them to GLACIER storage every 30 days. Glacier is another useful service from Amazon allowing inexpensive, highly durable storage services for archiving huge volumes of data. After a year of storage, we will likely delete it. Let’s look at the various metadata associated with it:
<LifecycleConfiguration> <Rule> <ID>multipart-upload-rule</ID> <Prefix></Prefix> <Status>Enabled</Status> <AbortIncompleteMultipartUpload> <DaysAfterInitiation>3</DaysAfterInitiation> </AbortIncompleteMultipartUpload> </Rule> </LifecycleConfiguration>
<LifecycleConfiguration> <Rule> <ID>CAImgRule</ID> <Prefix>cloudacademyblogimg/</Prefix> <Status>Enabled</Status> <Transition> <Days>90</Days> <StorageClass>GLACIER</StorageClass> </Transition> <Expiration> <Days>365</Days> </Expiration> </Rule> <Rule> <ID> CALogRule</ID> <Prefix> cloudacademylogs/</Prefix> <Status>Enabled</Status> <Transition> <Days>30</Days> <StorageClass>STANDARD_IA</StorageClass> </Transition> <Expiration> <Days>30</Days> </Expiration> </Rule> </LifecycleConfiguration>
aws s3api put-bucket-lifecycle --bucket bucketname --lifecycle-configuration filename-containing-lifecycle-configuration
Mastering ASW S3 policies and exceptions requires considerable energy. Cloud Academy can help. They offer a suite of products for developers learning ASW S3.
There are video courses, hands-on learning paths, and quizzes. Each component supports a professional approach to practical learning.
Video courses are created and narrated by working professional ASW developers who understand time constraints and deliver the information learners need for passing exams and, more importantly, excelling in a critical IT role.
People learn differently. Some students love quizzes because they help push information into a higher-level of mental storage. Others use quizzes for testing themselves and determining areas of strength and weakness for a personal approach. Cloud Academy Quizzes offer duel modes for maximum learning flexibility:
Most technical people agree project-based learning resonates most powerfully with them. Cloud Academy offers hands-on labs in an actual AWS environment. Students may experiment in a live ASW world without leaving the Cloud Academy site or signing up for services with AWS. This builds confidence and reinforces knowledge.
When you review this post, you’ll see we used the AWS Management Console to create and activate a rule. In a professional setting, a developer will likely require far more complex rules. This is more an opportunity than a challenge because there are tremendously good learning resources around AWS S3. Treat yourself to a free 7-day trial subscription to Cloud Academy where the above resources are all available. Training, personal determination, and AWS S3 documentation present a winning combination for career advancement.