

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

# AWS::Serverless::StateMachine
<a name="sam-resource-statemachine"></a>

 AWS Step Functions ステートマシンを作成します。ステートマシンを使用して、 AWS Lambda 関数やその他の AWS リソースをオーケストレーションし、複雑で堅牢なワークフローを形成できます。

Step Functions の詳細については、[AWS Step Functions デベロッパーガイド](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html)を参照してください。

**注記**  
にデプロイすると AWS CloudFormation、 は AWS SAM リソースを CloudFormation リソース AWS SAM に変換します。詳細については、「[の生成済み CloudFormation リソース AWS SAM](sam-specification-generated-resources.md)」を参照してください。

## 構文
<a name="sam-resource-statemachine-syntax"></a>

 AWS Serverless Application Model (AWS SAM) テンプレートでこのエンティティを宣言するには、次の構文を使用します。

### YAML
<a name="sam-resource-statemachine-syntax.yaml"></a>

```
Type: AWS::Serverless::StateMachine
Properties:
  AutoPublishAlias: {{String}}
  UseAliasAsEventTarget: {{Boolean}}
  [Definition](#sam-statemachine-definition): {{Map}}
  [DefinitionSubstitutions](#sam-statemachine-definitionsubstitutions): {{Map}}
  [DefinitionUri](#sam-statemachine-definitionuri): {{String | [S3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitions3location)}}
  DeploymentPreference: {{[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachinealias-deploymentpreference.html)}}
  [Events](#sam-statemachine-events): {{EventSource}}
  [Logging](#sam-statemachine-logging): {{[LoggingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-loggingconfiguration)}}
  [Name](#sam-statemachine-name): {{String}}
  [PermissionsBoundary](#sam-statemachine-permissionsboundary): {{String}}
  [Policies](#sam-statemachine-policies): {{String | List | Map}}
  PropagateTags: {{Boolean}}
  [RolePath](#sam-statemachine-rolepath): {{String}}
  [Role](#sam-statemachine-role): {{String}}
  [Tags](#sam-statemachine-tags): {{Map}}
  [Tracing](#sam-statemachine-tracing): {{[TracingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tracingconfiguration)}}
  [Type](#sam-statemachine-type): {{String}}
```

## プロパティ
<a name="sam-resource-statemachine-properties"></a>

 `AutoPublishAlias`   <a name="sam-statemachine-autopublishalias"></a>
ステートマシンエイリアスの名前です。Step Functions ステートマシンエイリアスの使用に関する詳細については、「AWS Step Functions デベロッパーガイド」の「[Versions and Aliases を使用して継続的なデプロイを管理する](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-cd-aliasing-versioning.html)」を参照してください。  
`DeploymentPreference` を使用して、エイリアスのデプロイ設定を実行します。を指定しない場合`DeploymentPreference`、 AWS SAM は新しいステートマシンバージョンに一度に移行するようにトラフィックを設定します。  
AWS SAM は、`Retain`デフォルトでバージョンの `DeletionPolicy`と `UpdateReplacePolicy`を に設定します。以前のバージョンは自動的に削除されません。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachineAlias`リソースの ` [ Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachinealias.html#cfn-stepfunctions-statemachinealias-name)`プロパティに直接渡されます。

 `UseAliasAsEventTarget`   <a name="sam-statemachine-usealiasaseventtarget"></a>
`AutoPublishAlias` プロパティを使用して作成されたエイリアスを、[Events](#sam-statemachine-events)として定義されたイベントソースのターゲットに渡すかどうかを指定します。  
エイリアスをイベントのターゲットとして使用するには、`True` を指定します。  
型: ブール  
*必須:* いいえ  
*デフォルト*: `False`  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

 `Definition`   <a name="sam-statemachine-definition"></a>
ステートマシン定義は オブジェクトで、オブジェクトの形式は JSON や YAML などの AWS SAM テンプレートファイルの形式と一致します。ステートマシンの定義は、[Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) に準拠しています。  
インラインステートマシンの定義例については、「[例](#sam-resource-statemachine--examples)」を参照してください。  
`Definition` または `DefinitionUri` を提供する必要があります。  
*タイプ*: マップ  
*必須*: 条件に応じて異なります  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のプロパティはありません。

 `DefinitionSubstitutions`   <a name="sam-statemachine-definitionsubstitutions"></a>
ステートマシン定義内のプレースホルダー変数のマッピングを指定する文字列対文字列のマップです。これは、実行時に取得した値 (組み込み関数からの値など) をステートマシン定義に挿入できるようにします。  
*タイプ*: マップ  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[DefinitionSubstitutions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitionsubstitutions)`プロパティに似ています。インラインステートマシン定義で組み込み関数が指定されている場合、 はこのプロパティにエントリ AWS SAM を追加してステートマシン定義に挿入します。

 `DefinitionUri`   <a name="sam-statemachine-definitionuri"></a>
[Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) で記述されたステートマシン定義の Amazon Simple Storage Service (Amazon S3) URI またはローカルファイルパスです。  
ローカルファイルパスを指定する場合は、定義が適切に変換されるようにするために、テンプレートが `sam deploy` または `sam package` コマンドを含むワークフローを実行する必要があります。これを行うには、バージョン 0.52.0 以降の AWS SAM CLI を使用する必要があります。  
`Definition` または `DefinitionUri` を提供する必要があります。  
*タイプ*: 文字列 \| [S3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitions3location)  
*必須*: 条件に応じて異なります  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[DefinitionS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-definitions3location)`プロパティに直接渡されます。

 `DeploymentPreference`   <a name="sam-statemachine-deploymentpreference"></a>
段階的なステートマシンデプロイを有効化して設定する設定です。Step Functions の段階的なデプロイに関する詳細については、「*AWS Step Functions Developer Guide*」の「[ Manage continuous deployments with versions and aliases](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-cd-aliasing-versioning.html)」を参照してください。  
このプロパティを設定する前に、`AutoPublishAlias` を指定してください。`DeploymentPreference` 設定は、`AutoPublishAlias` で指定されたエイリアスに適用されます。  
を指定すると`DeploymentPreference`、 は`StateMachineVersionArn`サブプロパティ値を自動的に AWS SAM 生成します。  
*タイプ*: [DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachinealias-deploymentpreference.html)  
*必須:* いいえ  
*CloudFormation compatibility*: `StateMachineVersionArn`プロパティ値 AWS SAM を生成して にアタッチ`DeploymentPreference`し、 `AWS::StepFunctions::StateMachineAlias`リソースの `[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachinealias.html#cfn-stepfunctions-statemachinealias-deploymentpreference)`プロパティ`DeploymentPreference`に渡します。

 `Events`   <a name="sam-statemachine-events"></a>
このステートマシンをトリガーするイベントを指定します。イベントは、1 つのタイプと、そのタイプに依存する一連のプロパティで構成されます。  
*タイプ*: [EventSource](sam-property-statemachine-statemachineeventsource.md)  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

 `Logging`   <a name="sam-statemachine-logging"></a>
どの実行履歴イベントがどこにログされるかを定義します。  
*タイプ*: [LoggingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-loggingconfiguration)  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[LoggingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-loggingconfiguration)`プロパティに直接渡されます。

 `Name`   <a name="sam-statemachine-name"></a>
ステートマシンの名前です。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[StateMachineName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-statemachinename)`プロパティに直接渡されます。

 `PermissionsBoundary`   <a name="sam-statemachine-permissionsboundary"></a>
このステートマシンの実行ロールに使用するアクセス許可境界の ARN です。このプロパティは、ユーザーのためにロールが生成される場合にのみ機能します。  
*タイプ*: 文字列  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::IAM::Role`リソースの `[PermissionsBoundary](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-permissionsboundary)`プロパティに直接渡されます。

 `Policies`   <a name="sam-statemachine-policies"></a>
このステートマシンの許可ポリシー。ポリシーは、ステートマシンのデフォルト AWS Identity and Access Management (IAM) 実行ロールに追加されます。  
このプロパティは、単一の値または値のリストを受け入れます。使用できる値は次のとおりです。  
+ [AWS SAMポリシーテンプレート](serverless-policy-templates.md).
+ [AWS  管理ポリシー](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies)または[カスタマー管理ポリシー](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#customer-managed-policies)の ARN。
+ 次の[リストから](https://github.com/aws/serverless-application-model/blob/develop/samtranslator/internal/data/aws_managed_policies.json)の AWS 管理ポリシーの名前。
+ マップとして YAML でフォーマットされた[インライン IAM ポリシー](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#inline-policies)。
`Role` プロパティを設定する場合、このプロパティは無視されます。
*タイプ*: 文字列 \| リスト \| マップ  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

`PropagateTags`  <a name="sam-statemachine-propagatetags"></a>
[AWS::Serverless::StateMachine](sam-specification-generated-resources-statemachine.md) が生成したリソースに `Tags` プロパティからのタグを渡すかどうかを指定します。`True` を指定して、生成されたリソースにタグを伝播します。  
型: ブール  
*必須:* いいえ  
*デフォルト*: `False`  
*CloudFormation 互換性*: このプロパティは に固有 AWS SAM であり、 CloudFormation 同等のものはありません。

 `Role`   <a name="sam-statemachine-role"></a>
このステートマシンの実行ロールとして使用する IAM ロールの ARN です。  
*タイプ*: 文字列  
*必須*: 条件に応じて異なります  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[ RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-rolearn)`プロパティに直接渡されます。

 `RolePath`   <a name="sam-statemachine-rolepath"></a>
ステートマシンの IAM 実行ロールへのパス。  
このプロパティは、ユーザーのためにロールが生成される場合にのみ機能します。`Role` プロパティでロールが指定されている場合は使用しないでください。  
*タイプ*: 文字列  
*必須*: 条件に応じて異なります  
*CloudFormation 互換性*: このプロパティは、 `AWS::IAM::Role`リソースの `[Path](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-path)`プロパティに直接渡されます。

 `Tags`   <a name="sam-statemachine-tags"></a>
ステートマシンと対応する実行ロールに追加されるタグを指定する文字列対文字列マップです。タグの有効なキーと値についての情報は、[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html) リソースの [Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags) プロパティを参照してください。  
*タイプ*: マップ  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine` resource の `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags)` プロパティに似ています。 は、このリソースと、それに対して生成されるデフォルトのロールに`stateMachine:createdBy:SAM`タグ AWS SAM を自動的に追加します。

 `Tracing`   <a name="sam-statemachine-tracing"></a>
ステートマシンで AWS X-Ray を有効にするかどうかを選択します。X-Ray の Step Functions との使用に関する詳細については、*AWS Step Functions デベロッパーガイド*の「[AWS X-Ray and Step Functions](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-xray-tracing.html)」を参照してください。  
*タイプ*: [TracingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tracingconfiguration)  
*必須:* いいえ  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[TracingConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tracingconfiguration)`プロパティに直接渡されます。

 `Type`   <a name="sam-statemachine-type"></a>
ステートマシンのタイプです。  
*有効な値*: `STANDARD` または `EXPRESS`  
タイプ：文字列  
*必須:* いいえ  
*デフォルト*: `STANDARD`  
*CloudFormation 互換性*: このプロパティは、 `AWS::StepFunctions::StateMachine`リソースの `[StateMachineType](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-statemachinetype)`プロパティに直接渡されます。

## 戻り値
<a name="sam-resource-statemachine-return-values"></a>

### 参照番号
<a name="sam-resource-statemachine-return-values-ref"></a>

このリソースの論理 ID を Ref 組み込み関数に提供すると、Ref は基盤となる `AWS::StepFunctions::StateMachine` リソースの Amazon リソースネーム (ARN) を返します。

`Ref` 関数の使用方法の詳細については、*AWS CloudFormation ユーザーガイド*の「[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)」を参照してください。

### Fn::GetAtt
<a name="sam-resource-statemachine-return-values-fn--getatt"></a>

`Fn::GetAtt` は、このタイプの指定された属性の値を返します。利用可能な属性とサンプル戻り値は以下のとおりです。

`Fn::GetAtt` の使用の詳細については、*AWS CloudFormation ユーザーガイド*の「[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html)」を参照してください。

`Name`  <a name="Name-fn::getatt"></a>
ステートマシンの名前 (`HelloWorld-StateMachine` など) を返します。

## 例
<a name="sam-resource-statemachine--examples"></a>

### ステートマシン定義ファイル
<a name="sam-resource-statemachine--examples--state-machine-definition-file"></a>

以下は、Lambda 関数によるステートマシンの呼び出しを許可するインラインステートマシン定義の例です。この例では、呼び出しを許可する適切なポリシーが `Role` プロパティで設定されることを想定している点に注意してください。`my_state_machine.asl.json` ファイルは [Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) で記述される必要があります。

この例では、`DefinitionSubstitution`エントリにより、ステートマシンは AWS SAM テンプレートファイルに宣言されたリソースを含めることができます。

#### YAML
<a name="sam-resource-statemachine--examples--state-machine-definition-file--yaml"></a>

```
MySampleStateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    DefinitionUri: statemachine/my_state_machine.asl.json
    Role: arn:aws:iam::123456123456:role/service-role/my-sample-role
    Tracing:
      Enabled: true
    DefinitionSubstitutions:
      MyFunctionArn: !GetAtt MyFunction.Arn
      MyDDBTable: !Ref TransactionTable
```

### インラインステートマシン定義
<a name="sam-resource-statemachine--examples--inline-state-machine-definition"></a>

以下は、インラインステートマシン定義の例です。

この例では、 AWS SAM テンプレートファイルは YAML で書き込まれるため、ステートマシン定義も YAML にあります。インラインステートマシン定義を JSON で宣言するには、 AWS SAM テンプレートファイルを JSON で書き込みます。

#### YAML
<a name="sam-resource-statemachine--examples--inline-state-machine-definition--yaml"></a>

```
MySampleStateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    Definition:
      StartAt: MyLambdaState
      States:
        MyLambdaState:
          Type: Task
          Resource: arn:aws:lambda:us-east-1:123456123456:function:my-sample-lambda-app
          End: true
    Role: arn:aws:iam::123456123456:role/service-role/my-sample-role
    Tracing:
      Enabled: true
```