s3.getLifeCycle()

tbruyelle edited this page May 25, 2012 · 2 revisions

About

S3 helper for getting the bucket's lifecycle configuration. An error is returned if the bucket has no lifecycle. If you want to catch this kind of error, check the error content like that :

if (error.document && error.document.Code == 'NoSuchLifecycleConfiguration') {
  // bucket has no lifecycle

The response is a Javascript object mapped from the XML S3 response.

<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
   <Rule>
      <ID>30-day-log-deletion-rule</ID>
      <Prefix>logs</Prefix>
      <Status>Enabled</Status>
      <Expiration>
         <Days>30</Days>
      </Expiration>
   </Rule>
</LifecycleConfiguration>

Reference

s3.getLifeCycle(callback)
  • 'callback' - the callback that is executed when the processing finishes. It has a couple of arguments: error and result.
    • If there's an error, the callback receives the error argument as Error instance.
    • If the error argument is null, then the response argument contains the response.headers object as returned by the node.js core HTTPS client.

This method returns a 400 error if the bucket has no lifecycle configuration (S3 behaviour).