Using a wildcard on S3 Event Notification prefix

Wildcards in prefix/suffix filters of Lambda are not supported and will never be since the asterisk (*) is a valid character that can be used in S3 object key names. However, you could somehow fix this problem by adding a filter in your Lambda function. For example:

First, get the source key:

var srcKey = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " "));

Then, check if it is inside the users folder:

if (srcKey.indexOf('/users/') === -1) {
    callback('Not inside users folder!');
    return;
}

No, you can't -- it's a literal prefix.

In your example, you could use either of these prefixes, depending on what else is in the bucket (if there are things sharing the common prefix that you don't want to match):

System-images/
System-images/users/

Tags:

Amazon S3