How to find out S3 Bucket last accessed time?

Viewed 16303

I have a use-case where I need to find out last accessed time of the S3 bucket, but I am not able to find a way to do so. Though, we can get LastModifiedTime or LastUpdatedTime for the bucket, but I couldn't find any AWS API, which can give me the last accessed time for the AWS S3 Bucket. One way to do this is to parse through all the objects inside the buckets, but that's a very expensive operation to do, which I can't afford. Can somebody help me in getting the LastAccessedTime for the AWS S3 Bucket? I am using Python with boto3.

4 Answers

I don't have a code ready to post as an answer but I have an approach by using which you can achieve it.

You can utilize the Amazon S3 server access logging

  1. S3 Server access logging provides detailed records of the requests that are made to objects in Amazon S3 buckets.
  2. Amazon S3 periodically collects access log records, consolidates the records in log files, and then uploads log files to your target bucket as log objects.
  3. Each log record consists of information such as bucket name, the operation in the request, and the time at which the request was received.
  4. S3 Server Access Log Format provides more details about the format of the log file.

You need to use the target bucket to get the required answer.

Related