Description
I'm trying to use AWS CDK to create an eventbridge rule.
The custom event will have a detail payload where I only want to match on events where order_item_id is null.
Here is the rule in cdk:
rule.addEventPattern({
account: ['xxxxxxxxx'],
detailType: ['inventory_adjusted'],
detail: {
'order_item_id': [null]
}
})
And according to aws documentation, this is allowed:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html
To match events where the value of responseElements is null, use the following pattern, which would match the event example.
{ "detail": { "responseElements": [null] } }
However, when deploying with cdk I get this error:
development failed: ValidationError: [/Resources/sendinventoryadjustmentstolambda8954C2E5/Type/EventPattern/detail/order_item_id/0] 'null' values are not allowed in templates >[/Resources/sendinventoryadjustmentstolambda8954C2E5/Type/EventPattern/detail/order_item_id/0] 'null' values are not allowed in templates
And here is the cdk synth for the area around the rule:
EventPattern:
account:
- "xxxxxxxxx"
detail-type:
- inventory_adjusted
detail:
order_item_id:
- null
Indeed it is null... which apparently isn't allowed in yaml template, but then how do I express this in CDK?
Reproduction Steps
create a rule that tries to match a null value for detail key
rule.addEventPattern({
account: ['xxxxxxxxx'],
detailType: ['inventory_adjusted'],
detail: {
'order_item_id': [null]
}
})
Error Log
development failed: ValidationError: [/Resources/sendinventoryadjustmentstolambda8954C2E5/Type/EventPattern/detail/order_item_id/0] 'null' values are not allowed in templates >[/Resources/sendinventoryadjustmentstolambda8954C2E5/Type/EventPattern/detail/order_item_id/0] 'null' values are not allowed in templates
Environment
- **CLI Version :
cdk --version
1.45.0 (build 0cfab15)
- Framework Version:
- **Node.js Version:
node -v
v11.15.0
- **OS : osX 10.14.6
- **Language (Version): typescript
Other
This is 🐛 Bug Report