

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# を使用した AWS SAM リソースのオーケストレーション AWS Step Functions
<a name="serverless-step-functions-in-sam"></a>

[AWS Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/) を使用して AWS Lambda 関数やその他の AWS リソースをオーケストレーションし、複雑で堅牢なワークフローを形成できます。Step Functions は、 AWS Lambda 関数などの AWS リソースが使用されるタイミングと条件をアプリケーションに指示します。これにより、複雑で堅牢なワークフローを形成するプロセスが簡素化されます。[AWS::Serverless::StateMachine](sam-resource-statemachine.md) を使用して、ワークフロー内の個々のステップを定義し、各ステップでリソースを関連付けてから、これらのステップを順番に並べます。また、必要な移行および条件も追加します。これにより、複雑で堅牢なワークフローを作成するプロセスが簡素化されます。

**注記**  
Step Functions ステートマシンを含む AWS SAM テンプレートを管理するには、 のバージョン 0.52.0 以降を使用する必要があります AWS SAM CLI。使用しているバージョンを確認するには、`sam --version` コマンドを実行します。

Step Functions は[タスク](https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html)と[ステートマシン](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-states.html)の概念に基づいています。ステートマシンは、JSON ベースの [Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) を使用して定義します。[Step Functions コンソール](https://console.aws.amazon.com/states/home?region=us-east-1#/) にはステートマシンの構造のグラフィカルなビューが表示されるので、ステートマシンのロジックを視覚的にチェックし、実行をモニタリングできます。

Step Functions が AWS Serverless Application Model (AWS SAM) でサポートされている場合は、次の操作を実行できます。
+  AWS SAM テンプレート内で直接、または別のファイルでステートマシンを定義する 
+  AWS SAM ポリシーテンプレート、インラインポリシー、または 管理ポリシーを使用してステートマシン実行ロールを作成する 
+ API Gateway または Amazon EventBridge イベントを使用して、 AWS SAM テンプレート内のスケジュールに従って、または API を直接呼び出すことによってステートマシンの実行をトリガーする
+ 一般的な Step Functions 開発パターン向けに利用できる [AWS SAM ポリシーテンプレート](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html)を使用する

## 例
<a name="serverless-step-functions-in-sam-example"></a>

次の AWS SAM テンプレートファイルのスニペット例では、定義ファイルで Step Functions ステートマシンを定義します。`my_state_machine.asl.json` ファイルは [Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) で記述される必要があることに注意してください。

```
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Sample SAM template with Step Functions State Machine

Resources:
  MyStateMachine:
    Type: AWS::Serverless::StateMachine
    Properties:
      DefinitionUri: statemachine/my_state_machine.asl.json
      ...
```

Step Functions ステートマシンを含むサンプル AWS SAM アプリケーションをダウンロードするには、 *AWS Step Functions デベロッパーガイド*の[「 を使用して Step Functions ステートマシンを作成する AWS SAM](https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-state-machine-using-sam.html)」を参照してください。

## 詳細情報
<a name="serverless-step-functions-in-sam-more-information"></a>

Step Functions とその での使用の詳細については AWS SAM、以下を参照してください。
+ [AWS Step Functions のしくみ](https://docs.aws.amazon.com/step-functions/latest/dg/how-step-functions-works.html)
+ [AWS Step Functions および AWS Serverless Application Model](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-sam-sfn.html)
+ [チュートリアル: を使用して Step Functions ステートマシンを作成する AWS SAM](https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-state-machine-using-sam.html)
+ [AWS SAM 仕様: AWS::Serverless::StateMachine](sam-resource-statemachine.md)