claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🔄aws-step-functions

プラグイン
aws-serverless
引数
[what workflow are you building?]

説明

AWS Step FunctionsのステートマシンをJSONataクエリ言語を使用してワークフローとして構築します。 Amazon States Language(ASL)の構造、ステートタイプ、変数、データ変換、エラーハンドリング、AWSサービスとの統合、およびJSONPathからJSONataクエリ言語へのマイグレーションについて網羅しています。

原文を表示

Build workflows with AWS Step Functions state machines using the JSONata query language. Covers Amazon States Language (ASL) structure, state types, variables, data transformation, error handling, AWS service integration, and migrating from the JSONPath to the JSONata query language.

ユースケース

  • ステートマシンをJSONataで構築するとき
  • ASLの構造を理解する必要があるとき
  • ワークフロー内でデータ変換を行うとき
  • JSONPathからJSONataへ移行するとき
  • AWSサービスとの統合を設定するとき

本文(日本語訳)

AWS Step Functions

概要

AWS Step Functions は Amazon States Language (ASL) を使用して、ステートマシンを JSON 形式で定義します。AWS Step Functions を利用することで、ワークフロー(ステートマシンとも呼ばれる)を作成し、分散アプリケーションの構築、プロセスの自動化、マイクロサービスのオーケストレーション、データおよび機械学習パイプラインの構築が可能です。

このスキルは ASL でステートマシンを記述するための包括的なガイダンスを提供し、以下の内容をカバーします:

  • ASL の構造と JSONata 式の構文
  • 利用可能な 8 種類のワークフローステートの詳細
  • $states 予約変数
  • Assign を使ったワークフロー変数
  • エラーハンドリング
  • AWS サービス統合パターン
  • データ変換およびアーキテクチャのサンプルコード
  • ステートマシンのバリデーションとテスト
  • JSONPath から JSONata への移行方法

参照ファイルの読み込みタイミング

ユーザーが取り組んでいる内容に応じて、適切な参照ファイルを読み込んでください:

  • ASL の構造ステートタイプTaskPassChoiceWaitSucceedFailParallelMapreferences/asl-state-types.md を参照
  • エラーハンドリングトラブルシューティングRetryCatchフォールバックエラーコードStates.TimeoutStates.ALLreferences/error-handling.md を参照
  • サービス統合Lambda invokeDynamoDBSNSSQSSDK 統合Resource ARNsyncasyncreferences/service-integrations.md を参照
  • JSONPath から JSONata への移行migrationInputPathParametersResultSelectorResultPathOutputPath組み込み関数Iteratorpayload テンプレートreferences/migrating-from-jsonpath-to-jsonata.md を参照
  • バリデーションリンティングテストTestStateモックユニットテストinspection levelDEBUGTRACEステートの検証単体テストreferences/validation-and-testing.md を参照
  • アーキテクチャパターンサンプルポーリングsaga補償処理scatter-gatherセマフォロックhuman-in-the-loopエスカレーションExpress から Standard への移行references/architecture-patterns.md を参照
  • データ変換JSONata 式フィルタリング集計文字列操作$reduce$lookup$toMillis$partition$parse$hash$uuidreferences/transforming-data.md を参照
  • ステートの入出力$statesAssignOutputArguments変数スコープ変数の制限評価順序ステート間のデータ受け渡しreferences/processing-state-inputs-and-outputs.md を参照
  • デプロイSAMCloudFormationIaCDefinitionSubstitutionsX-Ray トレーシングロギングaws-serverless-deployment スキル または deploy-on-aws プラグイン を参照

クイックリファレンス

Standard ワークフロー vs Express ワークフロー

Standard Express
最大実行時間 1 年 5 分
実行セマンティクス Exactly-once(厳密に 1 回) At-least-once(非同期) / At-most-once(同期)
実行履歴 90 日間保持、API 経由でクエリ可能 CloudWatch Logs のみ
最大スループット 2,000 実行/秒 100,000 実行/秒
料金モデル ステート遷移ごと 実行回数 + 実行時間ごと
.sync / .waitForTaskToken サポートあり サポートなし
最適なユースケース 監査可能な非冪等操作 高スループットな冪等イベント処理

Standard を選択する場合: 決済処理、注文管理、コンプライアンスワークフロー、二重実行が絶対に許されない処理。

Express を選択する場合: IoT データ取り込み、ストリーミング変換、モバイルバックエンド、高スループットで短命な処理。

ステートマシンのクエリ言語の設定

JSONata は ASL においてデータの参照と変換を行うための、モダンかつ推奨される方法です。JSONPath の 5 つの I/O フィールド(InputPathParametersResultSelectorResultPathOutputPath)を、Arguments(入力)と Output の 2 つに置き換えます。

トップレベルで有効化することで、すべてのステートに適用されます:

{ "QueryLanguage": "JSONata", "StartAt": "...", "States": {...} }

または、ステートごとに指定することで JSONPath から段階的に移行できます:

{ "Type": "Task", "QueryLanguage": "JSONata", ... }

JSONPath は引き続きサポートされておりQueryLanguage を省略した場合のデフォルトです。既存のステートマシンを移行する必要はありません。

ベストプラクティス

  • 新規ステートマシンでは、ユーザーが JSONPath を希望しない限り、トップレベルに "QueryLanguage": "JSONata" を設定する
  • Output は最小限に保つ — 現在のステートの直後のステートが必要とするデータのみを含める
  • 後続のステートで必要な変数は Output を介してデータを引き回すのではなく、Assign を使って保存する
  • 元のステート入力を参照する際は $states.input を使用する
  • 注意: AssignOutput は並行して評価されるため、Assign で設定した変数は同一ステートの Output では利用できない
  • JSONata 式は必ず定義済みの値を返さなければならない — $data.nonExistentField のように未定義フィールドを参照すると States.QueryEvaluationError がスローされる
  • 任意のステートから元のワークフロー入力にアクセスするには $states.context.Execution.Input を使用する
  • コンソール外で作業する場合、ステートマシンの定義ファイルは .asl.json 拡張子で保存する
  • SDK 統合よりも最適化された Lambda 統合(arn:aws:states:::lambda:invoke)を優先して使用する

トラブルシューティング

よくあるエラー

  • States.QueryEvaluationError — JSONata 式の実行に失敗。型エラー、未定義フィールド、範囲外の値がないか確認する。
  • 同一ステート内で JSONPath フィールドと JSONata フィールドを混在させている。
  • JSONata 式のトップレベルで $$$ を使用している — 代わりに $states.input を使用する。
  • JSONata 式を {% %} デリミタで囲み忘れている — デリミタがないと文字列リテラルとして扱われる。
  • Assign で設定した変数を同一ステートの Output で参照しようとしている — 新しい値は次のステートからのみ有効になる。
  • 詳細なトラブルシューティング情報については references/validation-and-testing.md および references/error-handling.md を参照する。

リソース

原文(English)を表示

AWS Step Functions

Overview

AWS Step Functions uses Amazon States Language (ASL) to define state machines as JSON. With AWS Step Functions, you can create workflows, also called State machines, to build distributed applications, automate processes, orchestrate microservices, and create data and machine learning pipelines.

This skill provides comprehensive guidance for writing state machines in ASL, covering:

  • ASL structure and JSONata expression syntax
  • Details on the eight available workflow states
  • The $states reserved variable
  • Workflow variables with Assign
  • Error handling
  • AWS Service integration patterns
  • Example code for data transformation and architecture
  • Validation and testing of state machines
  • How to migrate from JSONPath to JSONata

When to Load Reference Files

Load the appropriate reference file based on what the user is working on:

Quick Reference

Standard vs Express Workflows

Standard Express
Max duration 1 year 5 minutes
Execution semantics Exactly-once At-least-once (async) / At-most-once (sync)
Execution history Retained 90 days, queryable via API CloudWatch Logs only
Max throughput 2,000 exec/sec 100,000 exec/sec
Pricing model Per state transition Per execution count + duration
.sync / .waitForTaskToken Supported Not supported
Best for Auditable, non-idempotent operations High-volume, idempotent event processing

Choose Standard for: payment processing, order fulfillment, compliance workflows, anything that must never execute twice.

Choose Express for: IoT data ingestion, streaming transformations, mobile backends, high-throughput short-lived processing.

Setting the State Machine Query Language

JSONata is the modern, preferred way to reference and transform data in ASL. It replaces the five JSONPath I/O fields (InputPath, Parameters, ResultSelector, ResultPath, OutputPath) with just two: Arguments (inputs) and Output.

Enable at the top level to apply to all states:

{ "QueryLanguage": "JSONata", "StartAt": "...", "States": {...} }

Or per-state to migrate from JSONPath incrementally:

{ "Type": "Task", "QueryLanguage": "JSONata", ... }

JSONPath is still supported and is the default if QueryLanguage is omitted — existing state machines do not need to be migrated.

Best Practices

  • Set "QueryLanguage": "JSONata" at the top level for new state machines unless the user wants to use JSONPath
  • Keep Output minimal — only include what the state immediately after the current state needs
  • Use Assign to store variables needed in later states instead of threading it through Output
  • Use $states.input to reference original state input
  • Remember: Assign and Output are evaluated in parallel — variable assignments in Assign are NOT available in Output of the same state
  • All JSONata expressions must produce a defined value — $data.nonExistentField throws States.QueryEvaluationError
  • Use $states.context.Execution.Input to access the original workflow input from any state
  • Save state machine definitions with .asl.json extension when working outside the console
  • Prefer the optimized Lambda integration (arn:aws:states:::lambda:invoke) over the SDK integration

Troubleshooting

Common Errors

  • States.QueryEvaluationError — JSONata expression failed. Check for type errors, undefined fields, or out-of-range values.
  • Mixing JSONPath fields with JSONata fields in the same state.
  • Using $ or $$ at the top level of a JSONata expression — use $states.input instead.
  • Forgetting {% %} delimiters around JSONata expressions — the string will be treated as a literal.
  • Assigning variables in Assign and expecting them in Output of the same state — new values only take effect in the next state.
  • Reference references/validation-and-testing.md and references/error-handling.md for detailed troubleshooting information.

Resources

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。