Skip to content

Filter S3 Objects for S3 events with "=" in prefix

0

My Objects in S3 are organised in below format:

skey=aaaaa-aaaaa-aaaaa-aaaaa/Category=yyyyyyy/ts=20230826T052300Z/abc
skey=aaaaa-aaaaa-aaaaa-aaaaa/Category=zzzzzzz/ts=20200826T052300Z/xyz

I am wanting to get notifications for objects uploaded in Category=zzzzzzz category only to trigger a lambda. Can that be achieved somehow using S3 event notifications?

If i set prefix as below, notifications do not work. However they work if i leave prefix as blank.

skey=aaaaa-aaaaa-aaaaa-aaaaa/Category=zzzzzzz/
or
skey=aaaaa-aaaaa-aaaaa-aaaaa/Category=zzzzzzz/*
or 
skey=aaaaa-aaaaa-aaaaa-aaaaa/Category=zzzzzzz

whats the best solution to achieve notifications filtered on category here?

asked 2 years ago864 views

2 Answers
2
Accepted Answer

From the documentation (and also mentioned in the other answer):

A wildcard character ("*") can't be used in filters as a prefix or suffix. If your prefix or suffix contains a space, you must replace it with the "+" character. If you use any other special characters in the value of the prefix or suffix, you must enter them in URL-encoded (percent-encoded) format. For a complete list of special characters that must be converted to URL-encoded format when used in a prefix or suffix for event notifications, see Safe characters.

I tried to recreated your issue.

When I set the event to match on prefix skey=aaaaa-aaaaa-aaaaa-aaaaa/Category=zzzzzzz/ there was no match.

When I set the event to match on prefix skey%3Daaaaa-aaaaa-aaaaa-aaaaa/Category%3Dzzzzzzz/ there was a match and the lambda was triggered successfully.

Note that the prefix is case sensitive, double check that your folder is indeed as you've mentioned (e.g., skey all small case, Category with capital C).

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

1

Hi,

This page https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html will detail what to for S3 object names with special chars like "=".

As you will see there, the recommendation is to encode object names with such charss.

Best,

Didier

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.