5

I have orchestrated a data pipe line using AWS Step function. In last state I want to send a custom notification. I'm using an Intrinsic function States.Format to format my message and subject. It works fine for Context object element. Here, I have tested that in Message parameter. But it doesn't work with input JSON. This is my input JSON { "job-param":{ "pipe-line-name":"My pipe line name", "other-keys":"other values" } }

 "Success State": {
  "Type": "Task",     
  "Resource": "arn:aws:states:::sns:publish",
  "Parameters": {    

  "Message.$": "States.Format('Execution Id:{}, completed successfully!', $$.Execution.Id)",
  "Subject.$": "States.Format('[INFO] {} completed successfully!', $.job-param.pipe-line-name)",

  "TopicArn": "arn:aws:sns:us-east-1:************:sns-topic"
  },
  "End": true
}

While saving this state machine, it gives me following error message:

The value for the field 'Subject.$' must be a valid JSON Path

I checked Input and Result path. They have this value. I can directly use this value as parameter. This is working fine. But I can't format with other string.

"Subject.$": "$.job-param.pipe-line-name"

Alternate approach would be to call lambda to customize and trigger SNS. But I want to avoid that.

Can I request some suggestions to fix this error?

Thanks in advance!

1
  • Change your input JSON and replace - with _: ``` "Subject.$": "States.Format('[INFO] {} completed successfully!', $.job_param.pipe_line_name)", ``` Commented Nov 2, 2020 at 6:41

1 Answer 1

7

If you want to use any name with - in your JSON then you can write your JSON Path like this:

"Subject.$": "States.Format('[INFO] {} completed successfully!', $['job-param']['pipe-line-name'])",

But it would be easier if you change your input JSON and replace - with _:

"Subject.$": "States.Format('[INFO] {} completed successfully!', $.job_param.pipe_line_name)", 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Poorya, converting - to _ was not possible as in my case. But $['job-param']['pipe-line-name'] worked as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.