LoginSignup
1
2

More than 5 years have passed since last update.

aws-sdk-jsでAWS StepFunctions(に限らない)を非同期実行する

Posted at

StepFunctionsを結果不要で呼び出したい

AWS Lambda(Node.js)からAWS Step Functionsを起動する際に結果が不要でハンドリングも不要なシーンがありました。

LambdaのInvokeであれば InvocationTypeEvent を指定すれば非同期実行となりますが、StepFunctionsのstartExecutionにはそのようなオプションはありません。

AWS.Requestを使う

StepFunctionsに限らず、第2引数のcallbackを省略して戻り値の AWS.Requestsend メソッドを利用するとイベントループに残さずに非同期実行できます。
イベントループに残らないので、結果が出るまで無駄にLambdaの処理が課金されることがありません。(callbackWaitsForEmptyEventLoopはあまり変更したくない)

const params = {...};
stepFunctions.startExecution(params).send();
1
2
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
1
2