My Problem
I have a public S3 bucket which serves as a storage solution for large files (GBs) that I send to colleagues and clients. The files are auto-deleted after a few weeks.
The problem with this setting is that I may suffer significant charges if someone launches a DDOS and mass-downloads one of my links. I can end up paying huge egress network fees, and I want to avoid it.
One solution could be triggering a Lambda function whenever someone downloads an object, and increment a DynamoDB counter for the object. If the counter passes a reasonable threshold (say, 50 downloads), the Lambda function would make the file private to avoid further fees.
My Question
How can I configure a Lambda function to be triggered when someone requests a file from a specific S3 bucket?