AWS Steps - how to pass a dynamic JSON String


Hi, I'm trying to create an AWS Steps Machine, I've got the majority of it working now, except I want to send an SES V2 email, this takes a JSON string variable called Template Data, where I want to send dynamic values, and I cannot work out how to do this from steps.

Two things I've tried are;

"TemplateData.$": "States.Format('{ "name":"{}", "prizeValue": "{}", "emailAddress": "{}"}', $.Query.Item.Name.S, $.PrizeValue , $.Query.Item.Email.S)"

But as it uses {} as a variable placeholder, it won't let me use them elsewhere, I've tried escaping it to no avail.

I've also tried using something akin to

"TemplateData.$": "States.JsonToString({'Name.$' : 'Query.Item.Name'})"

But I get "The value for the field 'TemplateData.$' must be a valid JSONPath or a valid intrinsic function call (at /States/Parallel/Branches[1]/States/SendEmail (1)/Parameters)"

2 Answers

Did you try something like:

"TemplateData": {
  "name.$": "$.Query.Item.Name.S", 
  "prizeValue.$": "$.PrizeValue",
  "emailAddress.$": "$.Query.Item.Email.S"
profile picture
answered 2 months ago

Thank you very much - I think this is one of them moments where I was chasing my tail. I tried the above and it didn't work, I thought it was because the JSON passed in to TemplateData absolutely had to be stringified. However I've just tried it to paste the error message here and it's worked! I must have made a different mistake and presumed it wasn't the way to achieve it, when I should have gone back to it again. Thank you very much, my app is now ready for testing as that was the final piece!

answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions