

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 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 默认情况下，将版本`UpdateReplacePolicy``Retain`的`DeletionPolicy`和设置为。以前的版本不会被自动删除。  
*类型*：字符串  
*必需*：否  
*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` 属性创建的别名传递给使用[事件](#sam-statemachine-events)定义的事件源目标。  
指定 `True` 使用别名作为事件的目标。  
*类型*：布尔值  
*必需*：否  
*默认值*：`False`  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `Definition`   <a name="sam-statemachine-definition"></a>
状态机定义是一个对象，其中对象的格式与 AWS SAM 模板文件的格式相匹配，例如 JSON 或 YAML。状态机定义遵循 [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>
在状态机定义中指定占位符变量的映射的 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` 命令的工作流程才能使定义正确转换。为此，必须使用 AWS SAM CLI 版本 0.52.0 或更高版本。  
您必须提供 `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 兼容性*： AWS SAM 生成`StateMachineVersionArn`属性值并将其附加到资源的`[DeploymentPreference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachinealias.html#cfn-stepfunctions-statemachinealias-deploymentpreference)`属性，`DeploymentPreference`然后传递`DeploymentPreference`给`AWS::StepFunctions::StateMachineAlias`资源的属性。

 `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 policy](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 兼容性*：此属性类似于`AWS::StepFunctions::StateMachine`资源的`[Tags](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html#cfn-stepfunctions-statemachine-tags)`属性。 AWS SAM 自动为该资源以及为其生成的默认角色添加`stateMachine:createdBy:SAM`标签。

 `Tracing`   <a name="sam-statemachine-tracing"></a>
选择是否 AWS X-Ray 为状态机启用。有关使用 X-Ray 和 Step Functions 的更多信息，请参阅*《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 资源名称（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 中声明内联状态机定义，请使用 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 \$1 \$1 A [CloudWatchEvent](sam-property-statemachine-statemachinecloudwatchevent.md)pi [EventBridgeRule](sam-property-statemachine-statemachineeventbridgerule.md)](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-身份验证
<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)。  
*类型*：[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 规则的目标。有关更多信息，请参阅[什么是亚马逊 EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html) 在《*亚马逊 EventBridge 用户指南》*中。

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>
配置亚马逊简单队列服务 (Amazon SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的 Lambda 函数发送事件时，或者没有足够的权限调用 Lambda 函数 EventBridge 时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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>
使您可以根据特定事件数据向目标提供自定义输入的设置。您可以从事件中提取一个或多个键值对，然后使用该数据将自定义输入发送到目标。有关更多信息，请参阅《[亚马逊* EventBridge 用户指南》中的亚马逊 EventBridge *输入转换](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html)。  
*类型*：[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)。  
*类型*：[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` 对象。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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。  
*类型*：[目标](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 SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的状态机发送事件或调用状态机的权限不足时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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 资源名称（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>
指定了 AWS SAM 创建的死信队列的自定义名称。`Type`  
如果未设置 `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 规则的目标。有关更多信息，请参阅[什么是亚马逊 EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html) 在《*亚马逊 EventBridge 用户指南》*中。

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>
配置亚马逊简单队列服务 (Amazon SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的 Lambda 函数发送事件时，或者没有足够的权限调用 Lambda 函数 EventBridge 时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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` 对象。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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。  
*类型*：[目标](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 SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的状态机发送事件或调用状态机的权限不足时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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 资源名称（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>
指定了 AWS SAM 创建的死信队列的自定义名称。`Type`  
如果未设置 `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 S EventBridge cheduler 事件的目标。有关更多信息，请参阅[什么是 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 SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的 Lambda 函数发送事件时，或者没有足够的权限调用 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
```