I have an Amazon S3 bucket with a structure that resembles the following:
myBucket/
├─ username-at-gmail.com/
│ ├─ Results/
And what I want to do, using AWS SAM, is to set an event that listens to when anything in Results
is changed. I know that if there wasn't the issue of having the user's email, I could do it easily with a prefix. However, seeing that I can't hard code anything as this has to apply for all users, I'm not sure how to do this, if it's even possible. The only way I have thought of is to not set a prefix filter, and check once this event runs its lambda whether the event is running for a change in the right directory, but I know this is somewhat inefficient.
TIA
You should create an Amazon S3 event for the whole bucket.
Then, within the AWS Lambda function, you can extract the user's details from the supplied Key
of the object. The Lambda function can then take an appropriate action based on the user, or choose to ignore the event by doing nothing.
Do not worry about it being 'inefficient', since it is the only way to accomplish it.