I would like to filter a specific object from an array using a JSONPath filter expression within an AWS Step Function.
The JSONPath expression: $.IncidentRecordSummaries[?(@.Title==$.TitleFilter)].Arn
The data to filter on:
{
"TitleFilter": "ALARM [hello]",
"IncidentRecordSummaries": [
{
"Arn": "arn:aws:ssm-incidents::12345:incident-record/foo/abc",
"CreationTime": "2023-02-23T16:54:34.241Z",
"Impact": 3,
"IncidentRecordSource": {
"CreatedBy": "arn:aws:sts::12345:assumed-role/cs-mon-incidents-ms-ac-cloudwatch-sfn/step-functions-express-123",
"InvokedBy": "states.amazonaws.com",
"Source": "aws.cloudwatch"
},
"Status": "OPEN",
"Title": "ALARM [hello]"
},
{
"Arn": "arn:aws:ssm-incidents::12345:incident-record/bar/def",
"CreationTime": "2023-02-23T16:25:51.772Z",
"Impact": 3,
"IncidentRecordSource": {
"CreatedBy": "arn:aws:sts::12345:assumed-role/cs-mon-incidents-ms-pest-devops-guru-sfn/step-functions-express-456",
"InvokedBy": "states.amazonaws.com",
"Source": "aws.cloudwatch"
},
"Status": "OPEN",
"Title": "ALARM [world]"
}
]
}
Expected result:
["arn:aws:ssm-incidents::12345:incident-record/foo/abc"`]
Actual result:
[]
Any suggestion how to solve this issue?
The filter is working with a string literal being used in the expression: $.IncidentRecordSummaries[?(@.Title=='ALARM [hello]')].Arn returns the expected result.