

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 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 資源 AWS SAM 轉換為 CloudFormation 資源。如需詳細資訊，請參閱[為 產生 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
```

## Properties
<a name="sam-resource-statemachine-properties"></a>

 `AutoPublishAlias`   <a name="sam-statemachine-autopublishalias"></a>
狀態機器別名的名稱。若要進一步了解如何使用 Step Functions 狀態機器別名，請參閱《 *AWS Step Functions 開發人員指南*》中的[使用版本和別名管理持續部署](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>
狀態機器定義是一個物件，其中物件的格式與您的 AWS SAM 範本檔案格式相符，例如 JSON 或 YAML。狀態機器定義遵循 [Amazon 狀態語言](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>
string-to-string映射，指定狀態機器定義中預留位置變數的映射。這可讓您將執行時間取得的值 （例如，從內部函數） 注入狀態機器定義。  
*類型*：映射  
*必要*：否  
*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 Simple Storage Service (Amazon S3) URI 或以 [Amazon States Language](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html) 撰寫之狀態機器定義的本機檔案路徑。  
如果您提供本機檔案路徑，範本必須經過包含 `sam deploy`或 `sam package`命令的工作流程，才能正確轉換定義。若要這樣做，您必須使用 0.52.0 版或更新版本的 AWS SAM CLI。  
您必須提供 `Definition`或 `DefinitionUri`。  
*類型*：字串 \$1 [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 開發人員指南*》中的[使用版本和別名管理持續部署](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-cd-aliasing-versioning.html)。  
在設定此屬性`AutoPublishAlias`之前，請指定 。您的`DeploymentPreference`設定將套用至以 指定的別名`AutoPublishAlias`。  
當您指定 時`DeploymentPreference`， 會自動 AWS SAM 產生`StateMachineVersionArn`子屬性值。  
*類型*：[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-stepfunctions-statemachinealias-deploymentpreference.html)  
*必要*：否  
*CloudFormation compatibility*： AWS SAM 產生`StateMachineVersionArn`屬性值並將其連接至 `AWS::StepFunctions::StateMachineAlias` 資源的 `[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachinealias.html#cfn-stepfunctions-statemachinealias-deploymentpreference)` 屬性`DeploymentPreference`，並將其傳遞`DeploymentPreference`至 。

 `Events`   <a name="sam-statemachine-events"></a>
指定觸發此狀態機器的事件。事件由類型和一組屬性組成，這些屬性取決於類型。  
*類型*︰[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` 屬性，則會忽略此屬性。
*類型*：字串 \$1 清單 \$1 映射  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

`PropagateTags`  <a name="sam-statemachine-propagatetags"></a>
指出是否要將標籤從 `Tags` 屬性傳遞至您[AWS::Serverless::StateMachine](sam-specification-generated-resources-statemachine.md)產生的資源。指定 `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>
string-to-string映射，指定新增至狀態機器和對應執行角色的標籤。如需標籤有效索引鍵和值的資訊，請參閱 [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) 資源的[標籤](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags)屬性。  
*類型*：映射  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags)` `AWS::StepFunctions::StateMachine` resource. AWS SAM automatically 新增`stateMachine:createdBy:SAM`標籤至此資源，以及為其產生的預設角色。

 `Tracing`   <a name="sam-statemachine-tracing"></a>
選取是否 AWS X-Ray 已啟用狀態機器。如需搭配 Step Functions 使用 X-Ray 的詳細資訊，請參閱《 *AWS Step Functions 開發人員指南*》中的 [AWS X-Ray 和 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>

### Ref
<a name="sam-resource-statemachine-return-values-ref"></a>

當您將此資源的邏輯 ID 提供給 Ref 內部函數時，Ref 會傳回基礎`AWS::StepFunctions::StateMachine`資源的 Amazon Resource Name (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 語言](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 宣告內嵌狀態機器定義，請以 JSON 撰寫 AWS SAM 範本檔案。

#### 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
```

# EventSource
<a name="sam-property-statemachine-statemachineeventsource"></a>

描述觸發狀態機器之事件來源的物件。每個事件都包含一個類型和一組取決於該類型的屬性。如需每個事件來源屬性的詳細資訊，請參閱與該類型對應的子主題。

## 語法
<a name="sam-property-statemachine-statemachineeventsource-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Properties](#sam-statemachine-statemachineeventsource-properties): Schedule | ScheduleV2 | CloudWatchEvent | EventBridgeRule | Api
  [Type](#sam-statemachine-statemachineeventsource-type): String
```

## Properties
<a name="sam-property-statemachine-statemachineeventsource-properties"></a>

 `Properties`   <a name="sam-statemachine-statemachineeventsource-properties"></a>
描述此事件映射屬性的物件。屬性集必須符合定義的 `Type`。  
*類型*：[排程](sam-property-statemachine-statemachineschedule.md) \$1 [ScheduleV2](sam-property-statemachine-statemachineschedulev2.md) \$1 [CloudWatchEvent](sam-property-statemachine-statemachinecloudwatchevent.md) \$1 [EventBridgeRule](sam-property-statemachine-statemachineeventbridgerule.md) \$1 [Api](sam-property-statemachine-statemachineapi.md)  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Type`   <a name="sam-statemachine-statemachineeventsource-type"></a>
事件類型。  
*有效值*：`Api`、`Schedule`、`ScheduleV2`、`CloudWatchEvent`、 `EventBridgeRule`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-statemachine-statemachineeventsource--examples"></a>

### API
<a name="sam-property-statemachine-statemachineeventsource--examples--api"></a>

以下是 `API`類型事件的範例。

#### YAML
<a name="sam-property-statemachine-statemachineeventsource--examples--api--yaml"></a>

```
ApiEvent:
  Type: Api
  Properties:
    Method: get
    Path: /group/{user}
    RestApiId: 
      Ref: MyApi
```

# Api
<a name="sam-property-statemachine-statemachineapi"></a>

描述`Api`事件來源類型的物件。如果已定義[AWS::Serverless::Api](sam-resource-api.md)資源，路徑和方法值必須對應至 API OpenAPI 定義中的 操作。

## 語法
<a name="sam-property-statemachine-statemachineapi-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Auth](#sam-statemachine-statemachineapi-auth): ApiStateMachineAuth
  [Method](#sam-statemachine-statemachineapi-method): String
  [Path](#sam-statemachine-statemachineapi-path): String
  [RestApiId](#sam-statemachine-statemachineapi-restapiid): String
  UnescapeMappingTemplate: Boolean
```

## Properties
<a name="sam-property-statemachine-statemachineapi-properties"></a>

 `Auth`   <a name="sam-statemachine-statemachineapi-auth"></a>
此 API、路徑和方法的授權組態。  
當未指定 `DefaultAuthorizer` 時，使用此屬性覆寫個別路徑的 API `DefaultAuthorizer`設定，或覆寫預設設定`ApiKeyRequired`。  
*類型*：[ApiStateMachineAuth](sam-property-statemachine-apistatemachineauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Method`   <a name="sam-statemachine-statemachineapi-method"></a>
叫用此函數的 HTTP 方法。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Path`   <a name="sam-statemachine-statemachineapi-path"></a>
叫用此函數的 URI 路徑。值必須以 開頭`/`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `RestApiId`   <a name="sam-statemachine-statemachineapi-restapiid"></a>
`RestApi` 資源的識別符，其中必須包含具有指定路徑和方法的操作。一般而言，這會設定為參考此範本中定義的[AWS::Serverless::Api](sam-resource-api.md)資源。  
如果您未定義此屬性， 會使用產生的`OpenApi`文件 AWS SAM 建立預設[AWS::Serverless::Api](sam-resource-api.md)資源。該資源包含由相同範本中未指定 之`Api`事件定義的所有路徑和方法的聯集`RestApiId`。  
此屬性無法參考在另一個範本中定義的[AWS::Serverless::Api](sam-resource-api.md)資源。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `UnescapeMappingTemplate`   <a name="sam-statemachine-statemachineapi-unescapemappingtemplate"></a>
在傳遞給狀態機器的輸入上，將 取代`\'`為 `'`來取消單引號。當您的輸入包含單引號時，請使用 。  
如果設定為 `False`且您的輸入包含單引號，則會發生錯誤。
*類型*：布林值  
*必要*：否  
*預設值*：False  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

## 範例
<a name="sam-property-statemachine-statemachineapi--examples"></a>

### ApiEvent
<a name="sam-property-statemachine-statemachineapi--examples--apievent"></a>

以下是 `Api`類型事件的範例。

#### YAML
<a name="sam-property-statemachine-statemachineapi--examples--apievent--yaml"></a>

```
Events:
  ApiEvent:
    Type: Api
    Properties:
      Path: /path
      Method: get
```

# ApiStateMachineAuth
<a name="sam-property-statemachine-apistatemachineauth"></a>

為特定 API、路徑和方法設定事件層級的授權。

## 語法
<a name="sam-property-statemachine-apistatemachineauth-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [ApiKeyRequired](#sam-statemachine-apistatemachineauth-apikeyrequired): Boolean
  [AuthorizationScopes](#sam-statemachine-apistatemachineauth-authorizationscopes): List
  [Authorizer](#sam-statemachine-apistatemachineauth-authorizer): String
  [ResourcePolicy](#sam-statemachine-apistatemachineauth-resourcepolicy): ResourcePolicyStatement
```

## Properties
<a name="sam-property-statemachine-apistatemachineauth-properties"></a>

 `ApiKeyRequired`   <a name="sam-statemachine-apistatemachineauth-apikeyrequired"></a>
此 API、路徑和方法需要 API 金鑰。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `AuthorizationScopes`   <a name="sam-statemachine-apistatemachineauth-authorizationscopes"></a>
要套用至此 API、路徑和方法的授權範圍。  
如果您已指定 `DefaultAuthorizer` 屬性套用的任何範圍，您指定的範圍將會覆寫它。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Authorizer`   <a name="sam-statemachine-apistatemachineauth-authorizer"></a>
特定狀態機器`Authorizer`的 。  
如果您已指定 API 的全域授權方，並想要將此狀態機器設為公有，請將 `Authorizer`設定為 以覆寫全域授權方`NONE`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `ResourcePolicy`   <a name="sam-statemachine-apistatemachineauth-resourcepolicy"></a>
設定此 API 和路徑的資源政策。  
*類型*：[ResourcePolicyStatement](sam-property-statemachine-resourcepolicystatement.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-statemachine-apistatemachineauth--examples"></a>

### StateMachine-Auth
<a name="sam-property-statemachine-apistatemachineauth--examples--statemachine-auth"></a>

下列範例會在狀態機器層級指定授權。

#### YAML
<a name="sam-property-statemachine-apistatemachineauth--examples--statemachine-auth--yaml"></a>

```
Auth:
  ApiKeyRequired: true
  Authorizer: NONE
```

# ResourcePolicyStatement
<a name="sam-property-statemachine-resourcepolicystatement"></a>

為 API 的所有方法和路徑設定資源政策。如需資源政策的詳細資訊，請參閱《 [API Gateway 開發人員指南》中的使用 API Gateway 資源政策控制對 API 的存取](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies.html)。 **

## 語法
<a name="sam-property-statemachine-resourcepolicystatement-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [AwsAccountBlacklist](#sam-statemachine-resourcepolicystatement-awsaccountblacklist): List
  [AwsAccountWhitelist](#sam-statemachine-resourcepolicystatement-awsaccountwhitelist): List
  [CustomStatements](#sam-statemachine-resourcepolicystatement-customstatements): List
  [IntrinsicVpcBlacklist](#sam-statemachine-resourcepolicystatement-intrinsicvpcblacklist): List
  [IntrinsicVpcWhitelist](#sam-statemachine-resourcepolicystatement-intrinsicvpcwhitelist): List
  [IntrinsicVpceBlacklist](#sam-statemachine-resourcepolicystatement-intrinsicvpceblacklist): List
  [IntrinsicVpceWhitelist](#sam-statemachine-resourcepolicystatement-intrinsicvpcewhitelist): List
  [IpRangeBlacklist](#sam-statemachine-resourcepolicystatement-iprangeblacklist): List
  [IpRangeWhitelist](#sam-statemachine-resourcepolicystatement-iprangewhitelist): List
  [SourceVpcBlacklist](#sam-statemachine-resourcepolicystatement-sourcevpcblacklist): List
  [SourceVpcWhitelist](#sam-statemachine-resourcepolicystatement-sourcevpcwhitelist): List
```

## Properties
<a name="sam-property-statemachine-resourcepolicystatement-properties"></a>

 `AwsAccountBlacklist`   <a name="sam-statemachine-resourcepolicystatement-awsaccountblacklist"></a>
要封鎖 AWS 的帳戶。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `AwsAccountWhitelist`   <a name="sam-statemachine-resourcepolicystatement-awsaccountwhitelist"></a>
要允許 AWS 的帳戶。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型*：字串的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `CustomStatements`   <a name="sam-statemachine-resourcepolicystatement-customstatements"></a>
要套用至此 API 的自訂資源政策陳述式清單。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IntrinsicVpcBlacklist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpcblacklist"></a>
要封鎖的虛擬私有雲端 (VPCs) 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpcWhitelist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpcwhitelist"></a>
要允許的 VPCs 清單，其中每個 VPC 指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceBlacklist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpceblacklist"></a>
要封鎖的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `IntrinsicVpceWhitelist`   <a name="sam-statemachine-resourcepolicystatement-intrinsicvpcewhitelist"></a>
要允許的 VPC 端點清單，其中每個 VPC 端點指定為參考，例如[動態參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html)或`Ref`[內部函數](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html)。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeBlacklist`   <a name="sam-statemachine-resourcepolicystatement-iprangeblacklist"></a>
要封鎖的 IP 地址或地址範圍。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `IpRangeWhitelist`   <a name="sam-statemachine-resourcepolicystatement-iprangewhitelist"></a>
要允許的 IP 地址或地址範圍。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `SourceVpcBlacklist`   <a name="sam-statemachine-resourcepolicystatement-sourcevpcblacklist"></a>
要封鎖的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。如需此屬性的範例使用方式，請參閱此頁面底部的範例區段。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SourceVpcWhitelist`   <a name="sam-statemachine-resourcepolicystatement-sourcevpcwhitelist"></a>
要允許的來源 VPC 或 VPC 端點。來源 VPC 名稱必須以 開頭`"vpc-"`，來源 VPC 端點名稱必須以 開頭`"vpce-"`。  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-statemachine-resourcepolicystatement--examples"></a>

### 資源政策範例
<a name="sam-property-statemachine-resourcepolicystatement--examples--resource-policy-example"></a>

下列範例會封鎖兩個 IP 地址和來源 VPC，並允許 AWS 帳戶。

#### YAML
<a name="sam-property-statemachine-resourcepolicystatement--examples--resource-policy-example--yaml"></a>

```
Auth:
  ResourcePolicy:
    CustomStatements: [{
                         "Effect": "Allow",
                         "Principal": "*",
                         "Action": "execute-api:Invoke",
                         "Resource": "execute-api:/Prod/GET/pets",
                         "Condition": {
                           "IpAddress": {
                             "aws:SourceIp": "1.2.3.4"
                           }
                         }
                       }]
    IpRangeBlacklist:
      - "10.20.30.40"
      - "1.2.3.4"
    SourceVpcBlacklist:
      - "vpce-1a2b3c4d"
    AwsAccountWhitelist:
      - "111122223333"
    IntrinsicVpcBlacklist:
      - "{{resolve:ssm:SomeVPCReference:1}}" 
      - !Ref MyVPC
    IntrinsicVpceWhitelist:
      - "{{resolve:ssm:SomeVPCEReference:1}}" 
      - !Ref MyVPCE
```

# CloudWatchEvent
<a name="sam-property-statemachine-statemachinecloudwatchevent"></a>

描述`CloudWatchEvent`事件來源類型的物件。

AWS Serverless Application Model (AWS SAM) 會在設定此事件類型時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html) 資源。

**重要注意事項**： [EventBridgeRule](sam-property-statemachine-statemachineeventbridgerule.md)是要使用的慣用事件來源類型，而不是 `CloudWatchEvent`。 `EventBridgeRule` 和 `CloudWatchEvent`會使用相同的基礎服務、API CloudFormation 和資源。不過， AWS SAM 只會將新功能的支援新增至 `EventBridgeRule`。

## 語法
<a name="sam-property-statemachine-statemachinecloudwatchevent-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [EventBusName](#sam-statemachine-statemachinecloudwatchevent-eventbusname): String
  [Input](#sam-statemachine-statemachinecloudwatchevent-input): String
  [InputPath](#sam-statemachine-statemachinecloudwatchevent-inputpath): String
  [Pattern](#sam-statemachine-statemachinecloudwatchevent-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
```

## Properties
<a name="sam-property-statemachine-statemachinecloudwatchevent-properties"></a>

 `EventBusName`   <a name="sam-statemachine-statemachinecloudwatchevent-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-statemachine-statemachinecloudwatchevent-input"></a>
傳遞到目標的有效 JSON 文字。如果您使用此屬性，事件文字本身不會有任何內容傳遞到目標。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input)` 屬性。

 `InputPath`   <a name="sam-statemachine-statemachinecloudwatchevent-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

 `Pattern`   <a name="sam-statemachine-statemachinecloudwatchevent-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《Amazon [ EventBridge 使用者指南》中的 EventBridge 中的事件和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachinecloudwatchevent--examples"></a>

### CloudWatchEvent
<a name="sam-property-statemachine-statemachinecloudwatchevent--examples--cloudwatchevent"></a>

以下是`CloudWatchEvent`事件來源類型的範例。

#### YAML
<a name="sam-property-statemachine-statemachinecloudwatchevent--examples--cloudwatchevent--yaml"></a>

```
CWEvent:
  Type: CloudWatchEvent
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - running
```

# EventBridgeRule
<a name="sam-property-statemachine-statemachineeventbridgerule"></a>

描述`EventBridgeRule`事件來源類型的物件，這會將您的狀態機器設定為 Amazon EventBridge 規則的目標。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》中的[什麼是 Amazon EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html)。

AWS SAM 會在設定此事件類型時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html) 資源。

## 語法
<a name="sam-property-statemachine-statemachineeventbridgerule-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  DeadLetterConfig: DeadLetterConfig
  EventBusName: String
  Input: String
  InputPath: String
  InputTransformer: [InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)
  Pattern: [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  RetryPolicy: [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)
  RuleName: String
  State: String
  Target: Target
```

## Properties
<a name="sam-property-statemachine-statemachineeventbridgerule-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineeventbridgerule-deadletterconfig"></a>
設定在目標呼叫失敗後 EventBridge 傳送事件的 Amazon Simple Queue Service (Amazon SQS) 佇列。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinedeadletterconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `EventBusName`   <a name="sam-statemachine-statemachineeventbridgerule-eventbusname"></a>
與此規則相關聯的事件匯流排。如果您省略此屬性， AWS SAM 會使用預設事件匯流排。  
*類型：*字串  
*必要*：否  
*預設*：預設事件匯流排  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventBusName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventbusname)` 屬性。

 `Input`   <a name="sam-statemachine-statemachineeventbridgerule-input"></a>
傳遞到目標的有效 JSON 文字。如果您使用此屬性，事件文字本身不會有任何內容傳遞到目標。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input)` 屬性。

 `InputPath`   <a name="sam-statemachine-statemachineeventbridgerule-inputpath"></a>
當您不想將整個相符事件傳遞至目標時，請使用 `InputPath` 屬性來描述要傳遞的事件部分。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[InputPath](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputpath)` 屬性。

`InputTransformer`  <a name="sam-statemachine-statemachineeventbridgerule-inputtransformer"></a>
此設定能讓您以特定事件資料為基礎，向目標提供自訂輸入。您可從事件擷取一或多組鍵/值對，然後使用該資料將自訂輸入傳送至目標。如需詳細資訊，請參閱[《Amazon EventBridge 使用者指南》中的 Amazon EventBridge 輸入轉換](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html)。 * EventBridge *  
*類型*：[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputtransformer)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule``Target`資料類型的 `[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html) ` 屬性。

 `Pattern`   <a name="sam-statemachine-statemachineeventbridgerule-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《Amazon [ EventBridge 使用者指南》中的 EventBridge 中的事件和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eventbridge-and-event-patterns.html)。 * EventBridge *  
*類型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)` 屬性。

 `RetryPolicy`   <a name="sam-statemachine-statemachineeventbridgerule-retrypolicy"></a>
包含重試政策設定相關資訊的 `RetryPolicy` 物件。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)` 屬性。

 `RuleName`   <a name="sam-statemachine-statemachineeventbridgerule-rulename"></a>
 規則的名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name)` 屬性。

`State`  <a name="sam-statemachine-statemachineeventbridgerule-state"></a>
規則的狀態。  
*有效值*：`[ DISABLED | ENABLED ]`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。

 `Target`   <a name="sam-statemachine-statemachineeventbridgerule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-statemachine-statemachinetarget.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

## 範例
<a name="sam-property-statemachine-statemachineeventbridgerule--examples"></a>

### EventBridgeRule
<a name="sam-property-statemachine-statemachineeventbridgerule--examples--eventbridgerule"></a>

以下是`EventBridgeRule`事件來源類型的範例。

#### YAML
<a name="sam-property-statemachine-statemachineeventbridgerule--examples--eventbridgerule--yaml"></a>

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - terminated
```

# DeadLetterConfig
<a name="sam-property-statemachine-statemachinedeadletterconfig"></a>

用來指定 Amazon Simple Queue Service (Amazon SQS) 佇列的物件，其中 EventBridge 會在失敗的目標調用後傳送事件。例如，當將事件傳送至不存在的狀態機器，或沒有足夠的許可來叫用狀態機器時，叫用可能會失敗。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。

## 語法
<a name="sam-property-statemachine-statemachinedeadletterconfig-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Arn](#sam-statemachine-statemachinedeadletterconfig-arn): String
  [QueueLogicalId](#sam-statemachine-statemachinedeadletterconfig-queuelogicalid): String
  [Type](#sam-statemachine-statemachinedeadletterconfig-type): String
```

## Properties
<a name="sam-property-statemachine-statemachinedeadletterconfig-properties"></a>

 `Arn`   <a name="sam-statemachine-statemachinedeadletterconfig-arn"></a>
指定為無效字母佇列目標之 Amazon SQS 佇列的 Amazon Resource Name (ARN)。  
指定 `Type` 屬性或 `Arn` 屬性，但不能同時指定兩者。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `DeadLetterConfig` 資料類型的 `[Arn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-deadletterconfig.html#cfn-events-rule-deadletterconfig-arn)` 屬性。

 `QueueLogicalId`   <a name="sam-statemachine-statemachinedeadletterconfig-queuelogicalid"></a>
`Type` 指定 時 AWS SAM 建立的無效字母佇列自訂名稱。  
如果未設定 `Type` 屬性，則會忽略此屬性。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Type`   <a name="sam-statemachine-statemachinedeadletterconfig-type"></a>
佇列的類型。設定此屬性時， AWS SAM 會自動建立無效字母佇列，並連接必要的[資源型政策](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-perms)，以授予將事件傳送至佇列的規則資源許可。  
指定 `Type` 屬性或 `Arn` 屬性，但不能同時指定兩者。
*有效值*：`SQS`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-statemachine-statemachinedeadletterconfig--examples"></a>

### DeadLetterConfig
<a name="sam-property-statemachine-statemachinedeadletterconfig--examples--deadletterconfig"></a>

DeadLetterConfig

#### YAML
<a name="sam-property-statemachine-statemachinedeadletterconfig--examples--deadletterconfig--yaml"></a>

```
DeadLetterConfig:
  Type: SQS
  QueueLogicalId: MyDLQ
```

# Target
<a name="sam-property-statemachine-statemachinetarget"></a>

設定觸發規則時 EventBridge 叫用 AWS 的資源。

## 語法
<a name="sam-property-statemachine-statemachinetarget-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Id](#sam-statemachine-statemachinetarget-id): String
```

## Properties
<a name="sam-property-statemachine-statemachinetarget-properties"></a>

 `Id`   <a name="sam-statemachine-statemachinetarget-id"></a>
目標的邏輯 ID。  
的值`Id`可以包含英數字元、句點 (`.`)、連字號 (`-`) 和底線 ()`_`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[Id](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-id)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachinetarget--examples"></a>

### Target
<a name="sam-property-statemachine-statemachinetarget--examples--target"></a>

#### YAML
<a name="sam-property-statemachine-statemachinetarget--examples--target--yaml"></a>

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Target:
      Id: MyTarget
```

# Schedule
<a name="sam-property-statemachine-statemachineschedule"></a>

描述`Schedule`事件來源類型的物件，這會將您的狀態機器設定為依排程觸發之 EventBridge 規則的目標。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》中的[什麼是 Amazon EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html)。

AWS Serverless Application Model (AWS SAM) 會在設定此事件類型時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html) 資源。

## 語法
<a name="sam-property-statemachine-statemachineschedule-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [DeadLetterConfig](#sam-statemachine-statemachineschedule-deadletterconfig): DeadLetterConfig
  [Description](#sam-statemachine-statemachineschedule-description): String
  [Enabled](#sam-statemachine-statemachineschedule-enabled): Boolean
  [Input](#sam-statemachine-statemachineschedule-input): String
  [Name](#sam-statemachine-statemachineschedule-name): String
  [RetryPolicy](#sam-statemachine-statemachineschedule-retrypolicy): [RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)
  [RoleArn](#sam-statemachine-statemachineschedulev-rolearn): String
  [Schedule](#sam-statemachine-statemachineschedule-schedule): String
  [State](#sam-statemachine-statemachineschedule-state): String
  Target: Target
```

## Properties
<a name="sam-property-statemachine-statemachineschedule-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineschedule-deadletterconfig"></a>
設定 EventBridge 在目標呼叫失敗後傳送事件的 Amazon Simple Queue Service (Amazon SQS) 佇列。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinescheduledeadletterconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `Description`   <a name="sam-statemachine-statemachineschedule-description"></a>
規則的說明。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-description)` 屬性。

 `Enabled`   <a name="sam-statemachine-statemachineschedule-enabled"></a>
指出系統是否已啟用規則。  
若要停用規則，請將此屬性設定為 `false`。  
指定 `Enabled`或 `State` 屬性，但不能同時指定兩者。
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。如果此屬性設定為 `true`，則 AWS SAM 傳遞 `ENABLED`，否則傳遞 `DISABLED`。

 `Input`   <a name="sam-statemachine-statemachineschedule-input"></a>
傳遞到目標的有效 JSON 文字。如果您使用此屬性，事件文字本身不會有任何內容傳遞到目標。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule Target` 資源的 `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-input)` 屬性。

 `Name`   <a name="sam-statemachine-statemachineschedule-name"></a>
 規則的名稱。如果您未指定名稱， CloudFormation 會產生唯一的實體 ID，並使用該 ID 做為規則名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-name)` 屬性。

 `RetryPolicy`   <a name="sam-statemachine-statemachineschedule-retrypolicy"></a>
包含重試政策設定相關資訊的 `RetryPolicy` 物件。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)` 屬性。

 `RoleArn`   <a name="sam-statemachine-statemachineschedulev-rolearn"></a>
調用排程時EventBridge 排程器用於目標的 IAM 角色 ARN。  
*類型*：[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)  
*必要*：否。如果未提供，則會建立新的角色並使用。  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)` 屬性。

 `Schedule`   <a name="sam-statemachine-statemachineschedule-schedule"></a>
判斷何時及執行規則頻率的排程表達式。如需詳細資訊，請參閱[規則的排程運算式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[ScheduleExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-scheduleexpression)` 屬性。

 `State`   <a name="sam-statemachine-statemachineschedule-state"></a>
規則的狀態。  
*接受的值：* `DISABLED | ENABLED`  
指定 `Enabled`或 `State` 屬性，但不能同時指定兩者。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state)` 屬性。

 `Target`   <a name="sam-statemachine-statemachineschedule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-statemachine-statemachinetarget.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

## 範例
<a name="sam-property-statemachine-statemachineschedule--examples"></a>

### CloudWatch 排程事件
<a name="sam-property-statemachine-statemachineschedule--examples--cloudwatch-schedule-event"></a>

CloudWatch 排程事件範例

#### YAML
<a name="sam-property-statemachine-statemachineschedule--examples--cloudwatch-schedule-event--yaml"></a>

```
CWSchedule:
  Type: Schedule
  Properties:
    Schedule: 'rate(1 minute)'
    Name: TestSchedule
    Description: test schedule
    Enabled: false
```

# DeadLetterConfig
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig"></a>

用來指定 Amazon Simple Queue Service (Amazon SQS) 佇列的物件，其中 EventBridge 會在失敗的目標調用後傳送事件。例如，當將事件傳送至不存在的狀態機器，或沒有足夠的許可來叫用狀態機器時，叫用可能會失敗。如需詳細資訊，請參閱《*Amazon EventBridge 使用者指南*》中的[事件重試政策和使用無效字母佇列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。

## 語法
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Arn](#sam-statemachine-statemachinescheduledeadletterconfig-arn): String
  [QueueLogicalId](#sam-statemachine-statemachinescheduledeadletterconfig-queuelogicalid): String
  [Type](#sam-statemachine-statemachinescheduledeadletterconfig-type): String
```

## Properties
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig-properties"></a>

 `Arn`   <a name="sam-statemachine-statemachinescheduledeadletterconfig-arn"></a>
指定為無效字母佇列目標之 Amazon SQS 佇列的 Amazon Resource Name (ARN)。  
指定 `Type` 屬性或 `Arn` 屬性，但不能同時指定兩者。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `DeadLetterConfig` 資料類型的 `[Arn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-deadletterconfig.html#cfn-events-rule-deadletterconfig-arn)` 屬性。

 `QueueLogicalId`   <a name="sam-statemachine-statemachinescheduledeadletterconfig-queuelogicalid"></a>
`Type` 指定 時 AWS SAM 建立的無效字母佇列自訂名稱。  
如果未設定 `Type` 屬性，則會忽略此屬性。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Type`   <a name="sam-statemachine-statemachinescheduledeadletterconfig-type"></a>
佇列的類型。設定此屬性時， AWS SAM 會自動建立無效字母佇列，並連接必要的[資源型政策](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-perms)，以授予將事件傳送至佇列的規則資源許可。  
指定 `Type` 屬性或 `Arn` 屬性，但不能同時指定兩者。
*有效值*：`SQS`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig--examples"></a>

### DeadLetterConfig
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig--examples--deadletterconfig"></a>

DeadLetterConfig

#### YAML
<a name="sam-property-statemachine-statemachinescheduledeadletterconfig--examples--deadletterconfig--yaml"></a>

```
DeadLetterConfig:
  Type: SQS
  QueueLogicalId: MyDLQ
```

# Target
<a name="sam-property-statemachine-statemachinescheduletarget"></a>

設定觸發規則時 EventBridge 叫用 AWS 的資源。

## 語法
<a name="sam-property-statemachine-statemachinescheduletarget-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
  [Id](#sam-statemachine-statemachinescheduletarget-id): String
```

## Properties
<a name="sam-property-statemachine-statemachinescheduletarget-properties"></a>

 `Id`   <a name="sam-statemachine-statemachinescheduletarget-id"></a>
目標的邏輯 ID。  
的值`Id`可以包含英數字元、句點 (`.`)、連字號 (`-`) 和底線 ()`_`。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Events::Rule` `Target` 資料類型的 `[Id](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-id)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachinescheduletarget--examples"></a>

### Target
<a name="sam-property-statemachine-statemachinescheduletarget--examples--target"></a>

#### YAML
<a name="sam-property-statemachine-statemachinescheduletarget--examples--target--yaml"></a>

```
EBRule:
  Type: Schedule
  Properties:
    Target:
      Id: MyTarget
```

# ScheduleV2
<a name="sam-property-statemachine-statemachineschedulev2"></a>

描述`ScheduleV2`事件來源類型的物件，會將您的狀態機器設定為排程觸發的 Amazon EventBridge 排程器事件的目標。如需詳細資訊，請參閱《[EventBridge 排程器使用者指南》中的什麼是 Amazon EventBridge 排程器？](https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html)。 *EventBridge *

AWS Serverless Application Model (AWS SAM) 會在設定此事件類型時產生 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html) 資源。

## 語法
<a name="sam-property-statemachine-statemachineschedulev2-syntax"></a>

若要在 AWS Serverless Application Model (AWS SAM) 範本中宣告此實體，請使用下列語法。

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

```
DeadLetterConfig: DeadLetterConfig
[Description](#sam-statemachine-statemachineschedulev2-description): String
[EndDate](#sam-statemachine-statemachineschedulev2-enddate): String
[FlexibleTimeWindow](#sam-statemachine-statemachineschedulev2-flexibletimewindow): FlexibleTimeWindow
[GroupName](#sam-statemachine-statemachineschedulev2-groupname): String
[Input](#sam-statemachine-statemachineschedulev2-input): String
[KmsKeyArn](#sam-statemachine-statemachineschedulev2-kmskeyarn): String
[Name](#sam-statemachine-statemachineschedulev2-name): String
OmitName: Boolean
[PermissionsBoundary](#sam-statemachine-statemachineschedulev2-permissionsboundary): String
[RetryPolicy](#sam-statemachine-statemachineschedulev2-retrypolicy): RetryPolicy
[RoleArn](#sam-statemachine-statemachineschedulev2-rolearn): String
[ScheduleExpression](#sam-statemachine-statemachineschedulev2-scheduleexpression): String
[ScheduleExpressionTimezone](#sam-statemachine-statemachineschedulev2-scheduleexpressiontimezone): String
[StartDate](#sam-statemachine-statemachineschedulev2-startdate): String
[State](#sam-statemachine-statemachineschedulev2-state): String
```

## Properties
<a name="sam-property-statemachine-statemachineschedulev2-properties"></a>

 `DeadLetterConfig`   <a name="sam-statemachine-statemachineschedulev2-deadletterconfig"></a>
設定 Amazon Simple Queue Service (Amazon SQS) 佇列，EventBridge 會在目標呼叫失敗後傳送事件。例如，將事件傳送至不存在的 Lambda 函數時，或 EventBridge 沒有足夠的許可來叫用 Lambda 函數時，叫用可能會失敗。如需詳細資訊，請參閱《[EventBridge 排程器使用者指南》中的為 EventBridge 排程器設定無效字母佇列](https://docs.aws.amazon.com/scheduler/latest/UserGuide/configuring-schedule-dlq.html)。 *EventBridge *  
*類型*：[DeadLetterConfig](sam-property-statemachine-statemachinescheduledeadletterconfig.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Scheduler::Schedule``Target`資料類型的 `[DeadLetterConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-deadletterconfig)` 屬性。此屬性的 AWS SAM 版本包含其他子屬性，以防您想要為您 AWS SAM 建立無效字母佇列。

 `Description`   <a name="sam-statemachine-statemachineschedulev2-description"></a>
排程的描述。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[Description](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-description)` 屬性。

 `EndDate`   <a name="sam-statemachine-statemachineschedulev2-enddate"></a>
UTC 日期，排程可在此日期之前叫用其目標。視排程的週期運算式而定，叫用可能會在您指定的 **EndDate** 當天或之前停止。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[EndDate](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-enddate)` 屬性。

 `FlexibleTimeWindow`   <a name="sam-statemachine-statemachineschedulev2-flexibletimewindow"></a>
允許在其中叫用排程的時段組態。  
*類型*：[FlexibleTimeWindow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-flexibletimewindow)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[FlexibleTimeWindow](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler.html#cfn-scheduler-schedule-flexibletimewindow)` 屬性。

 `GroupName`   <a name="sam-statemachine-statemachineschedulev2-groupname"></a>
要與此排程建立關聯的排程群組名稱。如果未定義，則會使用預設群組。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[GroupName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname)` 屬性。

 `Input`   <a name="sam-statemachine-statemachineschedulev2-input"></a>
傳遞到目標的有效 JSON 文字。如果您使用此屬性，事件文字本身不會有任何內容傳遞到目標。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule Target` 資源的 `[Input](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-input)` 屬性。

 `KmsKeyArn`   <a name="sam-statemachine-statemachineschedulev2-kmskeyarn"></a>
KMS 金鑰的 ARN，將用於加密客戶資料。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-kmskeyarn)` 屬性。

 `Name`   <a name="sam-statemachine-statemachineschedulev2-name"></a>
排程的名稱。如果您未指定名稱， 會以 格式 AWS SAM 產生名稱`StateMachine-Logical-IDEvent-Source-Name`，並使用該 ID 做為排程名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-name)` 屬性。

`OmitName`  <a name="sam-statemachine-statemachineschedulev2-omitname"></a>
根據預設， AWS SAM 會產生並使用 *<State-machine-logical-ID><event-source-name>* 格式的排程名稱。將此屬性設定為 `true`，讓 CloudFormation 產生唯一的實體 ID，並改為將該 ID 用於排程名稱。  
*類型*：布林值  
*必要*：否  
*預設*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

 `PermissionsBoundary`   <a name="sam-statemachine-statemachineschedulev2-permissionsboundary"></a>
用來設定角色許可邊界的政策 ARN。  
如果`PermissionsBoundary`已定義 ， AWS SAM 會將相同的邊界套用至排程器排程的目標 IAM 角色。
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IAM::Role` 資源的 `[PermissionsBoundary](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-permissionsboundary)` 屬性。

 `RetryPolicy`   <a name="sam-statemachine-statemachineschedulev2-retrypolicy"></a>
包含重試政策設定相關資訊的 `RetryPolicy` 物件。  
*類型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-retrypolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-retrypolicy)` 屬性。

 `RoleArn`   <a name="sam-statemachine-statemachineschedulev2-rolearn"></a>
調用排程時EventBridge 排程器用於目標的 IAM 角色 ARN。  
*類型*：[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` `Target` 資料類型的 `[RoleArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)` 屬性。

 `ScheduleExpression`   <a name="sam-statemachine-statemachineschedulev2-scheduleexpression"></a>
排程表達式，可決定排程執行的時間和頻率。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[ScheduleExpression](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpression)` 屬性。

 `ScheduleExpressionTimezone`   <a name="sam-statemachine-statemachineschedulev2-scheduleexpressiontimezone"></a>
計算排程運算式所使用的時區。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[ScheduleExpressionTimezone](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-scheduleexpressiontimezone)` 屬性。

 `StartDate`   <a name="sam-statemachine-statemachineschedulev2-startdate"></a>
排程開始調用目標的日期，以 UTC 為單位。視排程的週期運算式而定，叫用可能會在您指定的 **StartDate** 當天或之後發生。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[StartDate](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-startdate)` 屬性。

 `State`   <a name="sam-statemachine-statemachineschedulev2-state"></a>
排程的狀態。  
*接受的值：* `DISABLED | ENABLED`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Scheduler::Schedule` 資源的 `[State](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-state)` 屬性。

## 範例
<a name="sam-property-statemachine-statemachineschedulev2--examples"></a>

### 定義 ScheduleV2 資源的基本範例
<a name="sam-property-statemachine-statemachineschedulev2--examples--example1"></a>

```
StateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    Name: MyStateMachine
    Events:
      ScheduleEvent:
        Type: ScheduleV2
        Properties:
          ScheduleExpression: "rate(1 minute)"
      ComplexScheduleEvent:
        Type: ScheduleV2
        Properties:
          ScheduleExpression: rate(1 minute)
          FlexibleTimeWindow:
            Mode: FLEXIBLE
            MaximumWindowInMinutes: 5
          StartDate: '2022-12-28T12:00:00.000Z'
          EndDate: '2023-01-28T12:00:00.000Z'
          ScheduleExpressionTimezone: UTC
          RetryPolicy:
            MaximumRetryAttempts: 5
            MaximumEventAgeInSeconds: 300
          DeadLetterConfig:
            Type: SQS
    DefinitionUri:
      Bucket: sam-sam-s3-demo-bucket
      Key: my-state-machine.asl.json
      Version: 3
    Policies:
      - LambdaInvokePolicy:
          FunctionName: !Ref MyFunction
```