AWS Steps - how to pass a dynamic JSON String

0

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 Respuestas
1

Did you try something like:

"TemplateData": {
  "name.$": "$.Query.Item.Name.S", 
  "prizeValue.$": "$.PrizeValue",
  "emailAddress.$": "$.Query.Item.Email.S"
}
profile pictureAWS
EXPERTO
Uri
respondido hace 2 años
0

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!

respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas