Closed lym953 closed 2 months ago
Oh, here's the answer. Giving an object a name that ends with .$
means "evaluate the value of this object, rename the object to strip off the ending .$
, and set the value of this object to be the evaluated value".
So, what's the right way to merge our Payload.$
with the customer's Payload
? Probably something like
if (step.Parameters.hasOwnProperty('Payload')) {
step.Parameters.Payload['State.$'] = '$$.State'
step.Parameters.Payload['StateMachine.$'] = '$$.StateMachine'
}
There are a couple other cases we should consider, I think:
- The customer has a
Payload
object (notPayload.$
). I'm not 100% sure what the.$
does in Cloudformation templates or the Stepfunction DSL, but the outcome seems to be that it turned into"Payload"
when the step function is executed.- If the customer has
Payload.$
orPayload
, should we merge our payload with theirs? Might be a broader discussion.
Good points! I'll do them in separate PRs to keep this PR minimal.
- If the customer has
Payload.$
orPayload
, should we merge our payload with theirs? Might be a broader discussion.
I think yes.
Payload
, e.g. https://github.com/DataDog/serverless-plugin-datadog/issues/517Updated the warning message to what @kimi-p drafted. Thanks for writing the message!
Branch report: yiming.luo/fix-step-func
Commit report: 4a069a4
Test service: datadog-ci-tests
:white_check_mark: 0 Failed, 364 Passed, 0 Skipped, 1m 26.51s Total duration (2m 1.59s time saved)
I found a bug: if traces merging is already set up and instrumentation command is run again, the warning will also be printed, which is wrong. I will fix this in a separate PR.
Background
The context injection for Lambda in Step Function requires the Lambda function requires the Lambda definition to be like
If the user has a custom
Payload.$
field, context injection will be skipped, but no error/warning message will be printed.What
Print a warning message if context injection is skipped if:
Parameters
field doesn't exist for the Lambda function, orPayload.$
fieldWhy
To make it transparent to users what won't work.
How?
Print the messages
Testing
Missing Parameters field
I wasn't able to test this because Parameters field is required when editing the State Machine from AWS Management Console. Should we remove this if-check?
Update: We are going to keep this if-check as @agocs suggested:
Custom Payload field
Message printed as expected:
Happy case
datadog-ci stepfunctions instrument
finishes with no errorReview checklist