Reputation: 181
I have an EventBridge event in a pattern similar to below.
{
"version": "0",
"id": "816c9de5-517b-a18a-1190-e3e3c2f51f92",
"detail-type": "ProductTableEvent",
"source": "pi-data",
"account": "751354400372",
"time": "2022-07-07T05:58:26Z",
"region": "eu-west-1",
"resources": [],
"detail": {
"data": {
"new": {
"Gtin": "01234567",
"NoIngredientsNeeded": 1,
"DeliveryCostIncluded": 0,
"MaximumOrder": 0,
"ProductSegment": "Vardag",
"StoreProducts": [],
}
}
}
}
And I want to write an event pattern that get triggers when the storeProducts List is not empty.
As not empty is not same as checking for null, I cant use anything-but rule that checks for null. So none of the below rules works here.
InsertProductRule:
Type: 'AWS::Events::Rule'
Properties:
EventBusName: commerce
EventPattern:
source:
- "my-source"
detail
data:
new:
StoreProducts:
- exists: true
- anything-but: []
Any idea how to do it?
Thank you very much!
Upvotes: 1
Views: 1953
Reputation: 26220
You can use the following pattern:
{
"source": ["pi-data"],
"detail": {
"data": {
"new": {
"StoreProducts": [{ "exists": true }]
}
}
}
}
this will be triggered when StoreProducts
is not an empty list.
When StoreProducts
is an empty list:
When StoreProducts
is not an empty list:
Upvotes: 4