Is there a way to pass through specific optional input parameters

0

Let's say I define a task state that invokes a Lambda. I'm wondering if there's a way I can pass through or default a specific optional input parameter in the Parameters property.

"someState": {
  "Type": "Task",
  "Resource": "arn:aws:states:::lambda:invoke",
  "Parameters": {
    "FunctionName": "someFunction",
    "InvocationType": "RequestResponse",
    "Qualifier.$": "$.environmentId",
    "Payload": {
      "environmentId.$": "$.environmentId",
      "someParameter.$": "$.someParameter",
    }
  }
}

If someParameter is included in the input I want it to be passed through. Else I'd want one of:

• Omit it.
• Be able to configure a default for it.
• Or if it even defaulted to null automatically, that'd be workable for me.

Is there a way to do that?

What actually happens is an error like:

{
  "error": "States.Runtime",
  "cause": "An error occurred while executing the state 'someState' (entered at the event id #7). The JSONPath '$.someParameter' specified for the field 'someParameter.$' could not be found in the input"
}

Consider this scenario: I have application environments staging and production that execute the step function. someFunction has aliases with those names.

I want someFunction to utilize a new request parameter that will be passed in the input to the step function.

The first thing that will happen is the Lambda code deployed to the staging alias will be updated to utilize the new parameter and the application running in the staging environment will pass it to the step function.

At this point the application running in the production environment will not have been updated to pass the new parameter to the step function.

So if I can just optionally pass through the new parameter, all would be well. But in reality it would break the production environment.

So far the best solution I can think of is to change to...

"Payload": "$"

...to pass everything through and pick out the parameters I'm interested in in the Lambda, but it means passing unnecessary data and the state configuration no longer documents the expected parameters.

Edited by: Jesse12345 on Nov 12, 2019 1:26 PM

Edited by: Jesse12345 on Nov 13, 2019 6:22 AM

  • This is not presently possible and is my most wanted feature for step functions. You can do tricks with the Pass state and the transient function States.JsonMerge but it's terribly inconvenient.

質問済み 4年前5696ビュー
2回答
0

Hi @Jesse12345

Could you find an answer to the question?

Also, your suggestion of "Payload": "$" might not work.
It will work if you change it to:

"Payload.$": "$"

Best,
Taha.

回答済み 4年前
0

I am facing the same issue. from my research it seems there is no good way to do this currently.

The only workaround I found was to use a "Choice" task:

See the article here:

https://medium.com/analytics-vidhya/aws-step-function-tricks-ffe7eef81a5e

alxd
回答済み 4年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ