Like websites we may need to add logs into our S3 bucket so that we can see what happens who added or deleted a certain file. This is very useful when we create a static website using S3 or we need logs for suspicious activity or find why we cannot access a file etc. When we add logging to our S3 bucket all our logs are stored in a different bucket in S3 and analyze them using various tools.
Now we will add access logs to S3 bucket.
- To add server access logs create a new bucket like we did in the previous articles.
This enables S3 logging in our bucket.
Now you can check that this generates logs by accessing our files in S3. Remember it takes a few hours for S3 to generate logs so don't worry
Now you can query these logs using Athena service in AWS by SQL very easily I'm attaching the link to the documentation where you can see how to use Athena to analyze your S3 logs
We have already learnt how to use S3. So now starting this article we are checking that how to make your S3 buckets more robust by logging. In the next article we will study how to Enable automatic backups using S3 replication so that anything cannot be deleted by mistake.