

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

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