

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

# 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) \| [Api](sam-property-function-api.md) \| [CloudWatchEvent](sam-property-function-cloudwatchevent.md) \| [CloudWatchLogs](sam-property-function-cloudwatchlogs.md) \| [Cognito](sam-property-function-cognito.md) \| [DocumentDB](sam-property-function-documentdb.md) \| [DynamoDB](sam-property-function-dynamodb.md) \| [EventBridgeRule](sam-property-function-eventbridgerule.md) \| [HttpApi](sam-property-function-httpapi.md) \| [IoTRule](sam-property-function-iotrule.md) \| [Kinesis](sam-property-function-kinesis.md) \| [MQ](sam-property-function-mq.md) \| [MSK](sam-property-function-msk.md) \| [S3](sam-property-function-s3.md) \| [Schedule](sam-property-function-schedule.md) \| [ScheduleV2](sam-property-function-schedulev2.md) \| [SelfManagedKafka](sam-property-function-selfmanagedkafka.md) \| [SNS](sam-property-function-sns.md) \| [SQS](sam-property-function-sqs.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
```