1

This is the attribute and value which my pub/sub subscription will be expected to filter:

'objectId': 'event-notifications-test/_MANIFEST'

However, I am not concerned about the prefix of the value (event-notifications-test/) changing - I only want to filter the message from the topic if it contains '_MANIFEST'. If I was interested in the prefix, I expect I would need to use something like this:

hasPrefix(attributes.name, "co")

How can I filter the message based on the suffix of the value i.e. '_MANIFEST'?

Dodo
  • 51
  • 1
  • 6

1 Answers1

2

It is not possible to filter directly on a suffix, no. Your two options are:

  1. When publishing, write the suffix out as a separate attribute.
  2. Filter at the application level when you receive a message by checking the suffix and acking the message without processing it.
Kamal Aboul-Hosn
  • 15,111
  • 1
  • 34
  • 46
  • Currently, I have a Cloud Storage bucket setup to write event notifications of type 'OBJECT_FINALIZE' to a pub/sub topic. Is there away to create this additional attribute in the current lifecyle I have setup or will I need to add an additional step of publishing the event notification to a Cloud Function or something and then writing it back to the pub/sub topic? – Dodo Jun 07 '22 at 13:54
  • I don't believe there is a way to do this directly with the GCS bucket notifications. You'd have to as you suggest and process the message via an intermediary Cloud Function and republish the message. At that point, option #2 might be better. – Kamal Aboul-Hosn Jun 07 '22 at 13:57