0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JSONPath @SFN

Posted at

ステートマシンの評価の流れ(概要)

① InputPath
② Parameters
③ Task 実行(Lambdaなど)
④ ResultSelector
⑤ ResultPath
⑥ OutputPath

ステートマシンの評価の流れ(解説)

① InputPath

ステートに渡す入力を絞る。大きな入力から必要部分だけを残す。

"InputPath": "$.s3"
② Parameters

InputPath後のデータを、タスク(Lambdaなど)に渡す形に整形。
.$付く → JSONPath評価
.$付かない → リテラル

"Parameters": {
  "bucket.$": "$.bucket",
  "key.$": "$.key"
}
③ Task 実行(Lambdaなど)

Lambda / ECS / AWS SDKなどを呼ぶ。

④ ResultSelector

タスクの結果を加工する。タスクの生結果だけが入力になる。

"ResultSelector": {
  "value.$": "$.Payload.result"
}
⑤ ResultPath

タスクの処理結果をどこに置くか。InputとResultの合成。
"ResultPath": null → 結果を捨てる
"ResultPath": $ → 全部上書き

"ResultPath": "$.lambdaResult"
挙動例
// 入力
{ "a": 1 }

// Result
{ "b": 2 }

// ResultPathの結果
{
  "a": 1,
  "lambdaResult": { "b": 2 }
}
⑥ OutputPath

次のステートに何を渡すか。

"OutputPath": "$.lambdaResult"

.$は要るのか要らないのか

場所 JSONPathを書く? .$ 必要?
InputPath 書く
OutputPath 書く
ResultPath 書く
Parameters 書く
ResultSelector 書く

.$は「値を評価するかどうかが曖昧な場所」でだけ必要。
Parameters, ResultSelector
 → JSONPathも文字列も数値もあり得るので、明示的に.$が必要。
  (ItemSelectorでも必要らしい)
InputPath, OutputPath, ResultPath
 → JSONPath前提だから不要。
  (ChoiceVariableも不要らしい)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?