組み込み関数の States.Array を使う
States.Array
This intrinsic takes zero or more arguments. The interpreter returns a JSON array containing the Values of the arguments, in the order provided. For example, given the following input:
{
"Id": 123456
}
> You could use
>```
"BuildId.$": "States.Array($.Id)"
Which would return “BuildId”: [123456]
Example
AWS SDK 統合で EC2 の StartInstances を call する場合場合、API パラメータは以下のような形式です。
{
"InstanceIds": [
"MyData"
]
}
ステートマシン実行時の Input で以下の入力を受け取る前提を考えたとき、
{
"InstanceId": "i-xxxxxxxxxxxxxxxxxxx"
}
API パラメータで以下のような設定でステートマシンを保存しようとするとエラーになります。
{
"InstanceIds.$": [
"$.InstanceId"
]
}
The value for the field 'InstanceIds.$' must be a STRING that contains a JSONPath but was an ARRAY
このようなケースで組み込み関数の States.Array を使用できます。
{
"InstanceIds.$": "States.Array($.InstanceId)"
}
結果として以下が返されるため、StartInsntaces を正常に実行できます。
{
"InstanceIds":[
"i-xxxxxxxxxxxxxxxxxxx"
]
}
簡単ですが、以上です。