Skip to content

API Gateway経由でStep Functionsを起動するサンプル

Notifications You must be signed in to change notification settings

heiwa4126/sam-stepfunctions-apigw

Repository files navigation

sam-stepfunctions-apigw

API Gateway経由でStep Functionsを起動するサンプル。

概要

ペイロードつけて/runを呼ぶと Step Functionsのstart-executionが実行されて executionArnが返ってくる。

Step Functionsはわざとlambda実行後10秒待つように書いてある。

executionArnを引数に/resultを時々呼ぶと lambdaでdescribe-executionが実行されてて、 結果がSUCCEEDEDなら答えが得られる。

これは簡易的なもの。

1000個程度のトランザクションはStep Functionsに保持されるらしい。 それ以上残したい場合はDynamoDBに入れる(TODO)

デプロイ

sam build
sam deploy --guided  # --guidedは最初の1回

sam deploy --guided

XXXFunction may not have authorization defined, Is this okay? [y/N]: y

以外はデフォルトでいいです。

デプロイが終わったら

./export1.sh  # 実行にはjqとyqとaws cliが必要

で、APIのURLを .export.sh に書き出してください。

テストの実行

./run_test.sh     # Step Functionの起動
./result_test.sh  # 起動して10秒以内に呼ぶと"RUNNING"になる
sleep 10
./result_test.sh  # Step Functionの結果の取得

スタックの削除

sam delete --no-prompts

で消えます。

About

API Gateway経由でStep Functionsを起動するサンプル

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published