'Google Cloud: Pubsub subscription filter expression options
I am trying to put filter in the GCP pubsub subscription. My requirement is to add number of codes in the filter. I am using terraform for that.
Here is something that I want to create :
filter = "attributes.code=(\"5426\",\"5427\",\"5428\",\"5429\",\"5430\")"
I checked the above will not work but the google docs have references to syntax something like:
filter = "attributes.code=\"5426\" OR attributes.code=\"5427\""
This one works, but there is a limit on the filter which is 256 bytes if I add all my codes like this then it is not going to work as it throws character limit error.
Is it possible to use RegEx in filter?
I can't do hit and trial as the code is in production so checking with the experts.
Solution 1:[1]
There's currently no support for regexes in Pub/Sub filters. You can follow updates on these filtering features on their public issue trackers:
In the meantime, could you potentially restructure your code formats to make use of the hasPrefix()
function? If you know in advance that you want to handle certain codes together in the same subscription, you could add common prefixes for them that you can later capture using hasPrefix()
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lauren |