2
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?

AWS Step Functions 入門

Last updated at Posted at 2025-06-28

AWS Step Functions を使ってみる

AWS Step Functions って何?

AWSの各種サービスを組み合わせて、一つの処理を組み上げるための仕組み。
繰り返しや条件分岐などのフロー制御や変数の利用も可能。いわゆるバッチ処理などを実現するためのサービス。

Step Functions が実現するワークフローの構成要素となる各ステップはステート(状態)と呼ばれる。これを組み上げて実現したい処理を構築する。

まずはチュートリアルで学ぼう

上記の入門チュートリアルに沿って、まずは Hello World するStep Functionsを作ってみると、雰囲気がつかめる。

JSONata

上記の入門チュートリアルでは、Step Functions の入力を参照するために以下のような書き方をしている

{
  "IsHelloWorldExample": "{% $states.input.hello_world %}",
  "ExecutionWaitTimeInSeconds":  "{% $states.input.wait %}"
}

ここの{% $states.input.hello_world %}の記法は、JSONataと呼ばれるものだそうです。

これを使うと、ステート間で受け渡しされるデータの変換処理を簡単に書くことができるらしい

※ 注意
現在(2025年6月)では、ステートマシンにおけるデータ変換言語としてはJSONataが既定で指定されていますが、JSONata の前はJSONPathというものが使われていました。
古い解説記事だとJSONataではなくJSONPath前提の説明になっていることがあるので要注意です。

aws cli から実行するには

この記事参照

aws stepfunctions list-state-machines でステートマシン一覧を取得したり、

 aws stepfunctions start-execution \
  --state-machine-arn {ステートマシンのARN} \
  --name `{ステートマシンの実行に付与する名前}` \
  --input {ステートマシンの入力として渡すJSONファイル}

で、ステートマシンを実行したりできる

--nameは省略すれば勝手にユニークな文字列をつけてくれる

その他

さらに調査して書きたい内容

  • ログやモニタリング
  • テスト・デバッグの手法
  • ECS タスクの起動および、コンテナの変数上書き
2
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
2
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?