Managing Versioning in S3 Bucket: Best Practices for Cost Optimization

Deleting Previous Versions of S3 Objects: 30-Day Retention Policy

Question

Your company owns a big data analysis application.

The application saves a large number of files in an S3 bucket.

Versioning has been enabled in the S3 bucket.

To save cost, you want to delete previous versions of objects in the S3 bucket after 30 days, and the current versions of objects should still be kept.

How would you implement this?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: A.

Option A is CORRECT because users should configure the S3 lifecycle rule as follows.

With this rule, the previous versions are permanently deleted after 30 days.

This method can effectively save costs.

Option B is incorrect because you cannot configure such an S3 lifecycle rule to disable versioning.

Option C is incorrect because you should not expire the current version as it will add a delete marker to it.

The current version should be kept according to the question.

Option D is incorrect because there is no need to delete expired delete markers.

This option does not delete previous versions of objects.

References:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html
ifecycle rule actions

Choose the actions you want this rule to perform, Per-request fees apply. Learn more [Zor see Amazon $3 pricing [7

Transition current versions of objects between storage classes
Transition previous versions of objects between storage classes
Expire current versions of objects

Permanently delete previous versions of objects

Delete expired delete markers or incomplete multipart uploads
‘When a lifecycle rule is scoped with tags, these actions are unavailable

Permanently delete previous versions of objects

Number of days after objects become previous versions

30

Timeline summary

Current version actions Previous version actions
Dayo Dayo

Objects uploaded Objects become noncurrent

v

Day 30

Objects are permanently deleted

The correct answer is option A: Create an S3 lifecycle rule and select the lifecycle rule action to be “Permanently delete previous versions of objects”.

Here is an explanation of why this is the correct option:

Amazon S3 provides a feature called lifecycle configuration, which automates the process of transitioning objects between different storage classes or deleting them when they are no longer needed. In this scenario, the requirement is to delete previous versions of objects after 30 days, while keeping the current versions.

To implement this requirement, an S3 lifecycle rule should be created for the S3 bucket that contains the objects. The lifecycle rule should specify that the previous versions of objects should be deleted after 30 days. To do this, the lifecycle rule action should be set to “Permanently delete previous versions of objects”.

Option B is not correct because disabling versioning does not accomplish the goal of keeping current versions of objects while deleting previous versions.

Option C is not correct because it would result in the deletion of all versions of the objects, including the current version.

Option D is not correct because it is used to delete expired delete markers for previous versions of objects, which is not relevant to this scenario.

In summary, option A is the correct answer because it meets the requirement of deleting previous versions of objects after 30 days while keeping the current versions.