Reputation: 225
I created an aws event bridge rule for slack. Now i would like to display different template based on a condition. The condition variable and its value will be part of the event message. I declare a variable into InputPathMap and used this variable as a condition parameter. I am getting an error when I deployed using SAM. It shows the variable value is null and did not deploy code to aws.
partial info of my rule.
...
InputTransformer:
InputPathsMap:
"actionMsg" : "$.detail.actionMsg"
"actionValue" : "$.detail.actionValue"
InputTemplate: !Sub >
!If [
<actionValue>,
{
"channel": "slackChannelName",
"text": "condition 1 : <actionMsg>"
...(more)
},
{
"channel": "slackChannelName",
"text": "condition 2 : <actionMsg>"
...(more)
}
]
I searched in google and saw the aws condition info. Can I set condition with the variable which I defined? Would you please give me an example, hints or link? I would appreciate.
Upvotes: 0
Views: 915
Reputation: 1326
This won't be possible to do within a single EventBridge Rule. You'll have to define separate 2 rules with an Event Pattern for each unique $detail.actionValue
that you care about.
A possible solution might be to define a rule with its own input transform and event pattern for matching your first condition
{
"...": "...",
"detail": {
"...": "...",
"actionValue": ["foo"]
}
Then define a "default rule" with your default input transform that catches everything except actionValue == "foo"
{
"...": "...",
"detail": {
"...": "...",
"actionValue": [ {"anything-but": ["foo"]} ]
}
Upvotes: 1