Single value extraction from ResultSelector in Step Function?

0

I'm struggling with something that seems like it should be simple, but the 'obvious' approach isn't working :-|. I have an AWS Step Function Lambda step. The input to that step (and function) looks like so:

{ "foo":"aaa" , "bar":"bbb" }

The Lambda's output looks like so:

{
  // a bunch of Lambda execution details here
  "Payload" : { "baz":"ccc" , "qux":"ddd" }
}

I'd like for the step's output to be:

{ "foo":"aaa" , "bar":"bbb" , "fred":"ccc" }

... i.e. I want to overlay the step's input with a new value at key "fred" referencing the Lambda output's value at "baz".

My first attempt (which still seems the most logical) is to 'extract' only "ccc" from the Lambda output and inject it into the step's output, like so:

"ResultSelector": "$.Payload.baz",
"ResultPath": "$.fred"

This puts the literal string "$.Payload.baz" into the output, not the dereferenced value.

It seems ResultSelector wants to build an object, so then I tried:

"ResultSelector": { "fred.$":"$.Payload.baz" },
"ResultPath": "$"

This replaces the entire step's input object, yielding just:

{ "fred":"ccc" }

And finally, the hybrid of those two:

"ResultSelector": { "fred.$":"$.Payload.baz" },
"ResultPath": "$.fred"

... yields:

{ "foo":"aaa" , "bar":"bbb", "fred":{"fred":"ccc"} }

Close (but no cigar): here it inserts the ResultSelector object into the output key, effectively 'nesting' the value I want ("ccc") one level too deep.

I'm a bit stumped for how to craft ResultSelector and ResultPath to achieve this simple overlay, and I feel like there's just some simple syntax trick that somehow I haven't found yet in the docs ... any ideas?

gefragt vor 8 Monaten317 Aufrufe
1 Antwort
0
Akzeptierte Antwort
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen