

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

# EventSource
<a name="sam-property-function-eventsource"></a>

描述触发函数的事件源的对象。每个事件都由一个类型和一组依赖于该类型的属性组成。有关每个事件源的属性的更多信息，请参阅与具体类型对应的主题。

## 语法
<a name="sam-property-function-eventsource-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-eventsource-syntax.yaml"></a>

```
  [Properties](#sam-function-eventsource-properties): {{AlexaSkill | Api | CloudWatchEvent | CloudWatchLogs | Cognito | DocumentDB | DynamoDB | EventBridgeRule | HttpApi | IoTRule | Kinesis | MQ | MSK | S3 | Schedule | ScheduleV2 | SelfManagedKafka | SNS | SQS}}
  [Type](#sam-function-eventsource-type): {{String}}
```

## Properties
<a name="sam-property-function-eventsource-properties"></a>

 `Properties`   <a name="sam-function-eventsource-properties"></a>
描述此事件映射的属性的对象。这组属性必须符合定义的类型。  
*类型* [[[[[：[AlexaSkill](sam-property-function-alexaskill.md)\| Ap [i](sam-property-function-api.md) \| \| \| Co [gnito [CloudWatchEvent[CloudWatchLogs](sam-property-function-cloudwatchlogs.md)](sam-property-function-cloudwatchevent.md)](sam-property-function-cognito.md)\| documentDB \| D [ynamo [DB](sam-property-function-documentdb.md) \| \| \| [Io](sam-property-function-iotrule.md) \| [Kinesis [EventBridgeRule](sam-property-function-eventbridgerule.md)\| MQ [HttpApi](sam-property-function-httpapi.md)\| MS](sam-property-function-kinesis.md) K TRule \| S3 \| 日程](sam-property-function-dynamodb.md)安排 \| Schedu [leV2 \| \|](sam-property-function-mq.md)[SNS \| SQ](sam-property-function-msk.md) S [SelfManagedKafka](sam-property-function-selfmanagedkafka.md)](sam-property-function-sqs.md)](sam-property-function-sns.md)](sam-property-function-schedulev2.md)](sam-property-function-schedule.md)](sam-property-function-s3.md)  
*是否必需*：是  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `Type`   <a name="sam-function-eventsource-type"></a>
事件类型。  
*有效值*：`AlexaSkill`, `Api`, `CloudWatchEvent`, `CloudWatchLogs`, `Cognito`, `DocumentDB`, `DynamoDB`, `EventBridgeRule`, `HttpApi`, `IoTRule`, `Kinesis`, `MQ`, `MSK`, `S3`, `Schedule`, `ScheduleV2`, `SelfManagedKafka`, `SNS`, `SQS`   
*类型*：字符串  
*是否必需*：是  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

## 示例
<a name="sam-property-function-eventsource--examples"></a>

### APIEvent
<a name="sam-property-function-eventsource--examples--apievent"></a>

使用 API 事件的示例

#### YAML
<a name="sam-property-function-eventsource--examples--apievent--yaml"></a>

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