2

I am trying to get the last access date of a resource in a bucket. But not able find anything related to it. I tried to fetch all the access logs for a bucket and parsed the logs files to check if a resource is accessed.

This is a very complex approach. In the

s3.listObjects I am getting the below object:-

 { Key: '_636579271588176973_951622.json',
       LastModified: 2018-08-02T08:31:29.000Z,
       ETag: '"c348574fabf83d603984a60983add161"',
       Size: 32172,
       StorageClass: 'STANDARD',
       Owner: [Object] },
Romain
  • 12,679
  • 3
  • 41
  • 54
Dinesh Rawat
  • 970
  • 10
  • 32

1 Answers1

4

S3 is merely an object storage solution from AWS and so doesn't hold information like file access time, etc.

As always there are workarounds to achieve this,

  • You may setup CloudTrail to get last access date to a resource based on resource type. Read more here.
  • You may make use of Server Access Logging on your bucket, and parse the logs to extract your last access date for the object. Read more here.
rahulpsd18
  • 641
  • 4
  • 12
  • Out of two approached, what approach is used widely? – Dinesh Rawat Aug 14 '18 at 11:25
  • There is no set way for this. It all depends, on what do you need, how do you need it, what else is that you will need, cost and pricing, delays, overheads, etc. With Server Access Logging way, you need to keep in mind that logs may arrive late, out of order (well, they have timestamps) or may not arrive at all in some rare cases. Never worked with CloudTrail, so can't comment. – rahulpsd18 Aug 14 '18 at 11:51
  • I got it and really helpful. Thanks – Dinesh Rawat Aug 14 '18 at 12:28