Lifecycle policies

Lifecycle policies are a great way to manage all the object lifecycles and achieve compliance. These rules are defined using XML and you can use the APIs to specify them. The following transitions are valid:

In our example we deal with hot objects accessed in real time, optimize them for Infrequent Access and then moved to a colder storage; in this case Amazon Glacier. After a year has passed the objects need to be deleted permanently.

To add a lifecycle rule, execute the following steps:

  1. Navigate to the bucket to be managed, choose the Management tab, and under Lifecycle choose + Add lifecycle rule:

  1. You will be prompted to choose a Name and scope for the rule, here you can use multiple object tags to filter and a prefix.

  1. In the step 2 Transitions, you can configure transitions for current versions and previous versions of the objects. Note that in order to transition the object to STANDARD_IA or ONEZONE_IA, the object needs to be stored in the STANDARD tier for 30 days, from STANDARD_IA to GLACIER 60 days is the minimum amount of time to optimize for archiving.

  1. In our scenario we'd like to remove all the objects after a year, so let's configure a rule to purge the objects which are the result of 60 days + 1 year after.

  1. Review the rules and transitions in step 4 on the Review screen, and you have created a fully managed object lifecycle policy.
  2. Let’s create another rule to transition objects from STANDARD storage to GLACIER after 15 days and delete them past 380 days, in this case, we will make use of the s3api CLI.

  1. Create the lifecycle configuration file (lifecycle.json):

And put the bucket lifecycle policy substituting the bucket name:

aws s3api put-bucket-lifecycle-configuration --bucket bucket_name --lifecycle-configuration file://lifecycle.json
  1. You can verify these changes in the console or by using the s3cli command:
aws s3api get-bucket-lifecycle-configuration --bucket bucket_name

You can download the JSON file here http://bit.ly/2yh3Ug0.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset