

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

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

# AlexaSkill
<a name="sam-property-function-alexaskill"></a>

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

## 語法
<a name="sam-property-function-alexaskill-syntax"></a>

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

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

```
  [SkillId](#sam-function-alexaskill-skillid): String
```

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

 `SkillId`   <a name="sam-function-alexaskill-skillid"></a>
Alexa Skill 的 Alexa Skill ID。如需技能 ID 的詳細資訊，請參閱 [Alexa Skills Kit 文件中的設定 Lambda 函數的觸發](https://developer.amazon.com/docs/custom-skills/host-a-custom-skill-as-an-aws-lambda-function.html#configuring-the-alexa-skills-kit-trigger)。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-function-alexaskill--examples"></a>

### AlexaSkillTrigger
<a name="sam-property-function-alexaskill--examples--alexaskilltrigger"></a>

Alexa 技能事件範例

#### YAML
<a name="sam-property-function-alexaskill--examples--alexaskilltrigger--yaml"></a>

```
AlexaSkillEvent:
  Type: AlexaSkill
```

# Api
<a name="sam-property-function-api"></a>

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

如果[AWS::Serverless::Api](sam-resource-api.md)未定義任何 ，則函數輸入和輸出代表 HTTP 請求和 HTTP 回應。

例如，使用 JavaScript API，可以透過傳回具有金鑰 statusCode 和內文的物件來控制回應statusCode和內文。

## 語法
<a name="sam-property-function-api-syntax"></a>

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

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

```
  [Auth](#sam-function-api-auth): ApiFunctionAuth
  [Method](#sam-function-api-method): String
  [Path](#sam-function-api-path): String
  [RequestModel](#sam-function-api-requestmodel): RequestModel
  [RequestParameters](#sam-function-api-requestparameters): List of [ String | RequestParameter ]
  [RestApiId](#sam-function-api-restapiid): String
  [ResponseTransferMode](#sam-function-api-responsetransfermode): String
  TimeoutInMillis: Integer
```

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

 `Auth`   <a name="sam-function-api-auth"></a>
此特定 Api\$1Path\$1Method 的身分驗證組態。  
用於在未`DefaultAuthorizer`指定或覆寫預設設定時，覆寫個別路徑上 API `DefaultAuthorizer` `ApiKeyRequired`的設定身分驗證組態。  
*類型*：[ApiFunctionAuth](sam-property-function-apifunctionauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Method`   <a name="sam-function-api-method"></a>
叫用此函數的 HTTP 方法。選項包括 `DELETE`、`GET`、`HEAD`、`OPTIONS`、`PATCH`、`PUT`、 `POST`和 `ANY`。如需詳細資訊，請參閱《 ** [API Gateway 開發人員指南》中的設定 HTTP 方法](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-settings-method-request.html#setup-method-add-http-method)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

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

 `RequestModel`   <a name="sam-function-api-requestmodel"></a>
請求使用此特定 Api\$1Path\$1Method 的模型。這應該參考 [AWS::Serverless::Api](sam-resource-api.md) 資源 `Models`區段中指定的模型名稱。  
*類型*：[RequestModel](sam-property-function-requestmodel.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `RequestParameters`   <a name="sam-function-api-requestparameters"></a>
請求此特定 Api\$1Path\$1Method 的參數組態。所有參數名稱都必須以 開頭`method.request.header`，`method.request`且必須限制為 `method.request.querystring`、 或 `method.request.path`。  
清單可以同時包含參數名稱字串和 [RequestParameter](sam-property-function-requestparameter.md) 物件。對於字串， `Required`和 `Caching` 屬性預設為 `false`。  
*類型*：【 String \$1 [RequestParameter](sam-property-function-requestparameter.md) 】 的清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `RestApiId`   <a name="sam-function-api-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 同等的。

`ResponseTransferMode`  <a name="sam-function-api-responsetransfermode"></a>
Lambda 函數整合的回應傳輸模式。設定為 `RESPONSE_STREAM` 以透過 API Gateway 啟用 Lambda 回應串流，允許函數將回應串流回用戶端。設為 時`RESPONSE_STREAM`，API Gateway 會使用 Lambda InvokeWithResponseStreaming API。  
*類型：*字串  
*必要*：否  
*有效值*：`BUFFERED` \$1 `RESPONSE_STREAM`  
*CloudFormation 相容性*：此屬性會直接傳遞至 的 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html#cfn-apigateway-method-integration-responsetransfermode](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html#cfn-apigateway-method-integration-responsetransfermode) 屬性`AWS::ApiGateway::Method Integration`。

`TimeoutInMillis`  <a name="sam-function-api-timeoutinmillis"></a>
自訂介於 50 和 29,000 毫秒之間的逾時。  
當您指定此屬性時， 會 AWS SAM 修改您的 OpenAPI 定義。OpenAPI 定義必須使用 `DefinitionBody` 屬性內嵌指定。
*類型*：整數  
*必要*：否  
*預設*：29，000 毫秒或 29 秒  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 屬性。

## 範例
<a name="sam-property-function-api--examples"></a>

### 基本範例
<a name="sam-property-function-api--examples--apievent"></a>

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

```
Events:
  ApiEvent:
    Type: Api
    Properties:
      Path: /path
      Method: get
      RequestParameters:
        - method.request.header.Authorization
        - method.request.querystring.keyword:
            Required: true
            Caching: false
```

# ApiFunctionAuth
<a name="sam-property-function-apifunctionauth"></a>

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

## 語法
<a name="sam-property-function-apifunctionauth-syntax"></a>

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

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

```
  [ApiKeyRequired](#sam-function-apifunctionauth-apikeyrequired): Boolean
  [AuthorizationScopes](#sam-function-apifunctionauth-authorizationscopes): List
  [Authorizer](#sam-function-apifunctionauth-authorizer): String
  [InvokeRole](#sam-function-apifunctionauth-invokerole): String
  OverrideApiAuth: Boolean
  [ResourcePolicy](#sam-function-apifunctionauth-resourcepolicy): ResourcePolicyStatement
```

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

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

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

 `Authorizer`   <a name="sam-function-apifunctionauth-authorizer"></a>
特定函數`Authorizer`的 。  
如果您為`AWS::Serverless::Api`資源指定了全域授權方，則可以將 `Authorizer`設定為 來覆寫授權方`NONE`。如需範例，請參閱 [覆寫 Amazon API Gateway REST API 的全域授權方](#sam-property-function-apifunctionauth--examples--override)。  
如果您使用 `AWS::Serverless::Api` 資源的 `DefinitionBody` 屬性來描述 API，則必須使用 `OverrideApiAuth`搭配 `Authorizer` 來覆寫您的全域授權方。如需詳細資訊，請參閱`OverrideApiAuth`。
*有效值*：`AWS_IAM`、 `NONE`或 AWS SAM 範本中定義之任何授權方的邏輯 ID。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，並且沒有 CloudFormation 同等的。

 `InvokeRole`   <a name="sam-function-apifunctionauth-invokerole"></a>
指定`InvokeRole`用於`AWS_IAM`授權的 。  
*類型：*字串  
*必要*：否  
*預設*：`CALLER_CREDENTIALS`  
*CloudFormation 相容性*：此屬性對 AWS SAM 是唯一的，並且沒有 CloudFormation 同等屬性。  
*其他備註*：`CALLER_CREDENTIALS`映射至 `arn:aws:iam:::<user>/`，這會使用呼叫者登入資料來叫用端點。

`OverrideApiAuth`  <a name="sam-function-apifunctionauth-overrideapiauth"></a>
將 指定為 `true`以覆寫`AWS::Serverless::Api`資源的全域授權方組態。只有在您指定全域授權方並使用 `AWS::Serverless::Api` 資源的 屬性來描述 API 時，才需要此`DefinitionBody`屬性。  
當您將 指定`OverrideApiAuth`為 時`true`， AWS SAM 會使用為 `ApiKeyRequired`、 `Authorizer`或 提供的任何值來覆寫您的全域授權方`ResourcePolicy`。因此，使用 時，至少也必須指定其中一個屬性`OverrideApiAuth`。如需範例，請參閱 [指定 DefinitionBody for AWS::Serverless::Api 時覆寫全域授權方](#sam-property-function-apifunctionauth--examples--override2)。
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

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

## 範例
<a name="sam-property-function-apifunctionauth--examples"></a>

### Function-Auth
<a name="sam-property-function-apifunctionauth--examples--function-auth"></a>

下列範例會在函數層級指定授權。

#### YAML
<a name="sam-property-function-apifunctionauth--examples--function-auth--yaml"></a>

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

### 覆寫 Amazon API Gateway REST API 的全域授權方
<a name="sam-property-function-apifunctionauth--examples--override"></a>

您可以為您的`AWS::Serverless::Api`資源指定全域授權方。以下是設定全域預設授權方的範例：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApiWithLambdaRequestAuth:
    Type: AWS::Serverless::Api
    Properties:
      ...
      Auth:
        Authorizers:
          MyLambdaRequestAuth:
            FunctionArn: !GetAtt MyAuthFn.Arn
        DefaultAuthorizer: MyLambdaRequestAuth
```

若要覆寫 AWS Lambda 函數的預設授權方，您可以將 指定`Authorizer`為 `NONE`。以下是範例：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  ...
  MyFn:
    Type: AWS::Serverless::Function
    Properties:
      ...
      Events:
        LambdaRequest:
          Type: Api
          Properties:
            RestApiId: !Ref MyApiWithLambdaRequestAuth
            Method: GET
            Auth:
              Authorizer: NONE
```

### 指定 DefinitionBody for AWS::Serverless::Api 時覆寫全域授權方
<a name="sam-property-function-apifunctionauth--examples--override2"></a>

使用 `DefinitionBody` 屬性描述`AWS::Serverless::Api`資源時，先前的覆寫方法無法運作。以下是將 `DefinitionBody` 屬性用於 `AWS::Serverless::Api` 資源的範例：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApiWithLambdaRequestAuth:
    Type: AWS::Serverless::Api
    Properties:
      ...
      DefinitionBody:
        swagger: 2.0
        ...
        paths:
          /lambda-request:
            ...
      Auth:
        Authorizers:
          MyLambdaRequestAuth:
            FunctionArn: !GetAtt MyAuthFn.Arn
        DefaultAuthorizer: MyLambdaRequestAuth
```

若要覆寫全域授權方，請使用 `OverrideApiAuth` 屬性。以下是使用 `OverrideApiAuth`以 提供的 值覆寫全域授權方的範例`Authorizer`：

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyApiWithLambdaRequestAuth:
    Type: AWS::Serverless::Api
    Properties:
      ...
      DefinitionBody:
        swagger: 2-0
        ...
        paths:
          /lambda-request:
            ...
      Auth:
        Authorizers:
          MyLambdaRequestAuth:
            FunctionArn: !GetAtt MyAuthFn.Arn
        DefaultAuthorizer: MyLambdaRequestAuth
    
    MyAuthFn:
      Type: AWS::Serverless::Function
      ...
    
    MyFn:
      Type: AWS::Serverless::Function
        Properties:
          ...
          Events:
            LambdaRequest:
              Type: Api
              Properties:
                RestApiId: !Ref MyApiWithLambdaRequestAuth
                Method: GET
                Auth:
                  Authorizer: NONE
                  OverrideApiAuth: true
                Path: /lambda-token
```

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

#### YAML
<a name="sam-property-function-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
```

# RequestModel
<a name="sam-property-function-requestmodel"></a>

設定特定 Api\$1Path\$1Method 的請求模型。

## 語法
<a name="sam-property-function-requestmodel-syntax"></a>

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

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

```
  [Model](#sam-function-requestmodel-model): String
  [Required](#sam-function-requestmodel-required): Boolean
  [ValidateBody](#sam-function-requestmodel-validatebody): Boolean
  [ValidateParameters](#sam-function-requestmodel-validateparameters): Boolean
```

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

 `Model`   <a name="sam-function-requestmodel-model"></a>
在 的模型屬性中定義的模型名稱[AWS::Serverless::Api](sam-resource-api.md)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Required`   <a name="sam-function-requestmodel-required"></a>
在指定 API 端點的 OpenApi 定義的參數區段中新增`required`屬性。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ValidateBody`   <a name="sam-function-requestmodel-validatebody"></a>
指定 API Gateway 是否使用 `Model` 驗證請求內文。如需詳細資訊，請參閱《 [API Gateway 開發人員指南》中的在 API Gateway 中啟用請求驗證](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html)。 **  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `ValidateParameters`   <a name="sam-function-requestmodel-validateparameters"></a>
指定 API Gateway 是否使用 `Model` 驗證請求路徑參數、查詢字串和標頭。如需詳細資訊，請參閱《 [API Gateway 開發人員指南》中的在 API Gateway 中啟用請求驗證](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html)。 **  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-function-requestmodel--examples"></a>

### 請求模型
<a name="sam-property-function-requestmodel--examples--request-model"></a>

請求模型範例

#### YAML
<a name="sam-property-function-requestmodel--examples--request-model--yaml"></a>

```
RequestModel:
  Model: User
  Required: true
  ValidateBody: true
  ValidateParameters: true
```

# RequestParameter
<a name="sam-property-function-requestparameter"></a>

設定特定 Api\$1Path\$1Method 的請求參數。

請求參數需要指定 `Required`或 `Caching` 屬性

## 語法
<a name="sam-property-function-requestparameter-syntax"></a>

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

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

```
  [Caching](#sam-function-requestparameter-caching): Boolean
  [Required](#sam-function-requestparameter-required): Boolean
```

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

 `Caching`   <a name="sam-function-requestparameter-caching"></a>
將 `cacheKeyParameters` 區段新增至 API Gateway OpenApi 定義  
*類型*：布林值  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Required`   <a name="sam-function-requestparameter-required"></a>
此欄位指定是否需要參數  
*類型*：布林值  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-function-requestparameter--examples"></a>

### 請求參數
<a name="sam-property-function-requestparameter--examples--request-parameter"></a>

設定請求參數的範例

#### YAML
<a name="sam-property-function-requestparameter--examples--request-parameter--yaml"></a>

```
RequestParameters:
  - method.request.header.Authorization:
      Required: true
      Caching: true
```

# CloudWatchEvent
<a name="sam-property-function-cloudwatchevent"></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-function-eventbridgerule.md)是要使用的慣用事件來源類型，而不是 `CloudWatchEvent`。 `EventBridgeRule` 和 `CloudWatchEvent`會使用相同的基礎服務、API CloudFormation 和資源。不過， AWS SAM 只會將新功能的支援新增至 `EventBridgeRule`。

## 語法
<a name="sam-property-function-cloudwatchevent-syntax"></a>

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

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

```
  [Enabled](#sam-function-cloudwatchevent-enabled): Boolean
  [EventBusName](#sam-function-cloudwatchevent-eventbusname): String
  [Input](#sam-function-cloudwatchevent-input): String
  [InputPath](#sam-function-cloudwatchevent-inputpath): String
  [Pattern](#sam-function-cloudwatchevent-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  [State](#sam-function-cloudwatchevent-state): String
```

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

 `Enabled`   <a name="sam-function-cloudwatchevent-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`。

 `EventBusName`   <a name="sam-function-cloudwatchevent-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-function-cloudwatchevent-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-function-cloudwatchevent-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-function-cloudwatchevent-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)` 屬性。

 `State`   <a name="sam-function-cloudwatchevent-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)` 屬性。

## 範例
<a name="sam-property-function-cloudwatchevent--examples"></a>

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

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

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

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

# CloudWatchLogs
<a name="sam-property-function-cloudwatchlogs"></a>

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

此事件會產生[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html)資源並指定訂閱篩選條件，並將其與指定的日誌群組建立關聯。

## 語法
<a name="sam-property-function-cloudwatchlogs-syntax"></a>

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

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

```
  [FilterPattern](#sam-function-cloudwatchlogs-filterpattern): String
  [LogGroupName](#sam-function-cloudwatchlogs-loggroupname): String
```

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

 `FilterPattern`   <a name="sam-function-cloudwatchlogs-filterpattern"></a>
篩選表達式，限制交付至目的地 AWS 資源的項目。如需篩選條件模式語法的詳細資訊，請參閱[篩選條件及模式語法](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Logs::SubscriptionFilter` 資源的 `[FilterPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html#cfn-cwl-subscriptionfilter-filterpattern)` 屬性。

 `LogGroupName`   <a name="sam-function-cloudwatchlogs-loggroupname"></a>
要與訂閱篩選條件關聯的日誌群組。如果篩選條件模式符合日誌事件，則上傳至此日誌群組的所有日誌事件都會經過篩選，並交付至指定的 AWS 資源。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Logs::SubscriptionFilter` 資源的 `[LogGroupName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html#cfn-cwl-subscriptionfilter-loggroupname)` 屬性。

## 範例
<a name="sam-property-function-cloudwatchlogs--examples"></a>

### Cloudwatchlogs 訂閱篩選條件
<a name="sam-property-function-cloudwatchlogs--examples--cloudwatchlogs-subscription-filter"></a>

Cloudwatchlogs 訂閱篩選條件範例

#### YAML
<a name="sam-property-function-cloudwatchlogs--examples--cloudwatchlogs-subscription-filter--yaml"></a>

```
CWLog:
  Type: CloudWatchLogs
  Properties:
    LogGroupName:
      Ref: CloudWatchLambdaLogsGroup
    FilterPattern: My pattern
```

# Cognito
<a name="sam-property-function-cognito"></a>

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

## 語法
<a name="sam-property-function-cognito-syntax"></a>

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

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

```
  [Trigger](#sam-function-cognito-trigger): List
  [UserPool](#sam-function-cognito-userpool): String
```

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

 `Trigger`   <a name="sam-function-cognito-trigger"></a>
新使用者集區的 Lambda 觸發組態資訊。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Cognito::UserPool` 資源的 `[LambdaConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-lambdaconfig.html)` 屬性。

 `UserPool`   <a name="sam-function-cognito-userpool"></a>
相同範本中定義的 UserPool 參考  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-function-cognito--examples"></a>

### Cognito 事件
<a name="sam-property-function-cognito--examples--cognito-event"></a>

Cognito 事件範例

#### YAML
<a name="sam-property-function-cognito--examples--cognito-event--yaml"></a>

```
CognitoUserPoolPreSignup:
  Type: Cognito
  Properties:
    UserPool:
      Ref: MyCognitoUserPool
    Trigger: PreSignUp
```

# DocumentDB
<a name="sam-property-function-documentdb"></a>

描述`DocumentDB`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon DocumentDB](https://docs.aws.amazon.com/lambda/latest/dg/with-documentdb.html)。

## 語法
<a name="sam-property-function-documentdb-syntax"></a>

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

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

```
BatchSize: Integer
Cluster: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
CollectionName: String
DatabaseName: String
Enabled: Boolean
FilterCriteria: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
FullDocument: String
KmsKeyArn: String  
MaximumBatchingWindowInSeconds: Integer
SecretsManagerKmsKeyId: String
SourceAccessConfigurations: List
StartingPosition: String
StartingPositionTimestamp: Double
```

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

 `BatchSize`   <a name="sam-function-documentdb-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。

 `Cluster`   <a name="sam-function-documentdb-cluster"></a>
Amazon DocumentDB 叢集的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `CollectionName`   <a name="sam-function-documentdb-collectionname"></a>
要在資料庫內使用的集合名稱。如果您未指定集合，Lambda 會使用所有集合。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping``DocumentDBEventSourceConfig`資料類型的 `[ CollectionName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-documentdbeventsourceconfig.html#cfn-lambda-eventsourcemapping-documentdbeventsourceconfig-collectionname)` 屬性。

 `DatabaseName`   <a name="sam-function-documentdb-databasename"></a>
Amazon DocumentDB 叢集內要使用的資料庫名稱。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping``DocumentDBEventSourceConfig`資料類型的 `[ DatabaseName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-documentdbeventsourceconfig.html#cfn-lambda-eventsourcemapping-documentdbeventsourceconfig-databasename)` 屬性。

 `Enabled`   <a name="sam-function-documentdb-enabled"></a>
如果為 `true`，則事件來源映射為作用中。若要暫停輪詢和調用，請將 設定為 `false`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-documentdb-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的 [ Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FullDocument`   <a name="sam-function-documentdb-fulldocument"></a>
決定 Amazon DocumentDB 在文件更新操作期間傳送到事件串流的內容。如果設定為 `UpdateLookup`，Amazon DocumentDB 會傳送描述變更的差異，以及整個文件的副本。否則，Amazon DocumentDB 只會傳送包含變更的部分文件。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping``DocumentDBEventSourceConfig`資料類型的 `[ FullDocument](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-documentdbeventsourceconfig.html#cfn-lambda-eventsourcemapping-documentdbeventsourceconfig-fulldocument)` 屬性。

 `KmsKeyArn`   <a name="sam-function-documentdb-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-documentdb-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `SecretsManagerKmsKeyId`   <a name="sam-function-documentdb-secretsmanagerkmskeyid"></a>
 AWS Secrets Manager 的客戶受管金鑰的 AWS Key Management Service (AWS KMS) 金鑰 ID。當您使用 Secrets Manager 的客戶受管金鑰搭配不包含 `kms:Decrypt`許可的 Lambda 執行角色時，此為必要項目。  
此屬性的值是 UUID。例如：`1abc23d4-567f-8ab9-cde0-1fab234c5d67`。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 的。

 `SourceAccessConfigurations`   <a name="sam-function-documentdb-sourceaccessconfigurations"></a>
身分驗證通訊協定或虛擬主機的陣列。使用 [ SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) 資料類型指定此項目。  
對於`DocumentDB`事件來源類型，唯一的有效組態類型為 `BASIC_AUTH`。  
+ `BASIC_AUTH` – 存放代理程式登入資料的 Secrets Manager 秘密。對於此類型，登入資料必須採用下列格式：`{"username": "your-username", "password": "your-password"}`。僅允許一個 類型的物件`BASIC_AUTH`。
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)` 屬性。

 `StartingPosition`   <a name="sam-function-documentdb-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-documentdb-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

## 範例
<a name="sam-property-function-documentdb-examples"></a>

### Amazon DocumentDB 事件來源
<a name="sam-property-function-documentdb-examples-example1"></a>

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
    ...
      Events:
        MyDDBEvent:
          Type: DocumentDB
          Properties:
            Cluster: "arn:aws:rds:us-west-2:123456789012:cluster:docdb-2023-01-01"
            BatchSize: 10
            MaximumBatchingWindowInSeconds: 5
            DatabaseName: "db1"
            CollectionName: "collection1"
            FullDocument: "UpdateLookup"
            SourceAccessConfigurations:
              - Type: BASIC_AUTH
                URI: "arn:aws:secretsmanager:us-west-2:123456789012:secret:doc-db"
```

# DynamoDB
<a name="sam-property-function-dynamodb"></a>

描述`DynamoDB`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon DynamoDB](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html)。

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

## 語法
<a name="sam-property-function-dynamodb-syntax"></a>

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

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

```
  [BatchSize](#sam-function-dynamodb-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-dynamodb-bisectbatchonfunctionerror): Boolean
  [DestinationConfig](#sam-function-dynamodb-destinationconfig): [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)
  [Enabled](#sam-function-dynamodb-enabled): Boolean
  [FilterCriteria](#sam-function-dynamodb-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-dynamodb-functionresponsetypes): List
  KmsKeyArn: String          
  [MaximumBatchingWindowInSeconds](#sam-function-dynamodb-maximumbatchingwindowinseconds): Integer
  [MaximumRecordAgeInSeconds](#sam-function-dynamodb-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-dynamodb-maximumretryattempts): Integer
  [MetricsConfig](#sam-function-dynamodb-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)
  [ParallelizationFactor](#sam-function-dynamodb-parallelizationfactor): Integer
  [StartingPosition](#sam-function-dynamodb-startingposition): String
  StartingPositionTimestamp: Double
  [Stream](#sam-function-dynamodb-stream): String
  [TumblingWindowInSeconds](#sam-function-dynamodb-tumblingwindowinseconds): Integer
```

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

 `BatchSize`   <a name="sam-function-dynamodb-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`1000`

 `BisectBatchOnFunctionError`   <a name="sam-function-dynamodb-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `DestinationConfig`   <a name="sam-function-dynamodb-destinationconfig"></a>
捨棄記錄的 Amazon Simple Queue Service (Amazon SQS) 佇列或 Amazon Simple Notification Service (Amazon SNS) 主題目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)` 屬性。

 `Enabled`   <a name="sam-function-dynamodb-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-dynamodb-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-dynamodb-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-dynamodb-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-dynamodb-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-dynamodb-maximumrecordageinseconds"></a>
Lambda 傳送給函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-dynamodb-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `MetricsConfig`   <a name="sam-function-dynamodb-metricsconfig"></a>
選擇加入組態，以取得擷取每個處理階段之事件來源映射的增強指標。如需範例，請參閱 [MetricsConfig 事件](#sam-property-function-dynamodb-example-metricsconfigevent)。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `ParallelizationFactor`   <a name="sam-function-dynamodb-parallelizationfactor"></a>
要同時處理每個碎片的批次數量。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ParallelizationFactor](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-parallelizationfactor)` 屬性。

 `StartingPosition`   <a name="sam-function-dynamodb-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-dynamodb-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Stream`   <a name="sam-function-dynamodb-stream"></a>
DynamoDB 串流的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `TumblingWindowInSeconds`   <a name="sam-function-dynamodb-tumblingwindowinseconds"></a>
處理時段的持續時間，以秒為單位。有效範圍為 1 到 900 (15 分鐘）。  
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[輪轉視窗](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#streams-tumbling)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[TumblingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-tumblingwindowinseconds)` 屬性。

## 範例
<a name="sam-property-function-dynamodb--examples"></a>

### MetricsConfig 事件
<a name="sam-property-function-dynamodb-example-metricsconfigevent"></a>

以下是 資源的範例，該資源使用 `MetricsConfig` 屬性來擷取其事件來源映射的每個處理階段。

```
Resources:
  FilteredEventsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/metricsConfig.zip
      Handler: index.handler
      Runtime: nodejs16.x
      Events:
        KinesisStream:
          Type: Kinesis
          Properties:
            Stream: !GetAtt KinesisStream.Arn
            StartingPosition: LATEST
            MetricsConfig:
              Metrics:
              - EventCount
```

### 現有 DynamoDB 資料表的 DynamoDB 事件來源
<a name="sam-property-function-dynamodb--examples--dynamodb-event-source-for-existing-dynamodb-table"></a>

 AWS 帳戶中已存在的 DynamoDB 資料表的 DynamoDB 事件來源。

#### YAML
<a name="sam-property-function-dynamodb--examples--dynamodb-event-source-for-existing-dynamodb-table--yaml"></a>

```
Events:
  DDBEvent:
    Type: DynamoDB
    Properties:
      Stream: arn:aws:dynamodb:us-east-1:123456789012:table/TestTable/stream/2016-08-11T21:21:33.291
      StartingPosition: TRIM_HORIZON
      BatchSize: 10
      Enabled: false
```

### 範本中宣告的 DynamoDB 資料表的 DynamoDB 事件
<a name="sam-property-function-dynamodb--examples--dynamodb-event-for-dynamodb-table-declared-in-template"></a>

在相同範本檔案中宣告的 DynamoDB 資料表的 DynamoDB 事件。

#### YAML
<a name="sam-property-function-dynamodb--examples--dynamodb-event-for-dynamodb-table-declared-in-template--yaml"></a>

```
Events:
  DDBEvent:
    Type: DynamoDB
    Properties:
      Stream: 
        !GetAtt MyDynamoDBTable.StreamArn   # This must be the name of a DynamoDB table declared in the same template file
      StartingPosition: TRIM_HORIZON
      BatchSize: 10
      Enabled: false
```

# EventBridgeRule
<a name="sam-property-function-eventbridgerule"></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) 資源。 AWS SAM 也會建立 資源`AWS::Lambda::Permission`，這是必要的，以便 `EventBridgeRule`可以呼叫 Lambda。

## 語法
<a name="sam-property-function-eventbridgerule-syntax"></a>

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

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

```
  [DeadLetterConfig](#sam-function-eventbridgerule-deadletterconfig): DeadLetterConfig
  [EventBusName](#sam-function-eventbridgerule-eventbusname): String
  [Input](#sam-function-eventbridgerule-input): String
  [InputPath](#sam-function-eventbridgerule-inputpath): String
  InputTransformer: [InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)
  [Pattern](#sam-function-eventbridgerule-pattern): [EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)
  [RetryPolicy](#sam-function-eventbridgerule-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](#sam-function-eventbridgerule-target): Target
```

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

 `DeadLetterConfig`   <a name="sam-function-eventbridgerule-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)。  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型 `DeadLetterQueue`，可處理成功叫用目標 Lambda 函數後發生的失敗。這些失敗類型的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。
*類型*：[DeadLetterConfig](sam-property-function-deadletterconfig.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-function-eventbridgerule-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-function-eventbridgerule-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-function-eventbridgerule-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-function-eventbridgerule-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-function-eventbridgerule-pattern"></a>
說明哪些事件會路由到指定目標。如需詳細資訊，請參閱《[Amazon EventBridge ](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html) 使用者指南》中的 Amazon [EventBridge 事件和 EventBridge 事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-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-function-eventbridgerule-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-function-eventbridgerule-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-function-eventbridgerule-state"></a>
規則的狀態。  
*接受的值*： `DISABLED` \$1 `ENABLED` \$1 `ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS`  
*類型：*字串  
*必要*：否  
*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-function-eventbridgerule-target"></a>
EventBridge 在觸發規則時叫用 AWS 的資源。您可以使用此屬性來指定目標的邏輯 ID。如果未指定此屬性，則 AWS SAM 會產生目標的邏輯 ID。  
*類型*：[Target](sam-property-function-target.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性類似於 `AWS::Events::Rule` 資源的 `[Targets](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-targets)` 屬性。 `Amazon EC2 RebootInstances API call` 是目標屬性的範例。此屬性的 AWS SAM 版本只允許您指定單一目標的邏輯 ID。

## 範例
<a name="sam-property-function-eventbridgerule--examples"></a>

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

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

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

```
EBRule:
  Type: EventBridgeRule
  Properties:
    Input: '{"Key": "Value"}'
    Pattern:
      detail:
        state:
          - terminated
    RetryPolicy:
      MaximumRetryAttempts: 5
      MaximumEventAgeInSeconds: 900
    DeadLetterConfig:
      Type: SQS
      QueueLogicalId: EBRuleDLQ
    Target:
      Id: MyTarget
```

# DeadLetterConfig
<a name="sam-property-function-deadletterconfig"></a>

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

**注意**  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型，`DeadLetterQueue`可處理成功調用目標 Lambda 函數後發生的失敗。此類故障的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。

## 語法
<a name="sam-property-function-deadletterconfig-syntax"></a>

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

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

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

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

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

 `Type`   <a name="sam-function-deadletterconfig-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-function-deadletterconfig--examples"></a>

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

DeadLetterConfig

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

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

# Target
<a name="sam-property-function-target"></a>

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

## 語法
<a name="sam-property-function-target-syntax"></a>

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

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

```
  [Id](#sam-function-target-id): String
```

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

 `Id`   <a name="sam-function-target-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-function-target--examples"></a>

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

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

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

# HttpApi
<a name="sam-property-function-httpapi"></a>

描述具有 HttpApi 類型的事件來源的物件。

如果 API 上存在指定路徑和方法的 OpenApi 定義，SAM 會為您新增 Lambda 整合和安全性區段 （如適用）。

如果 API 上沒有指定路徑和方法的 OpenApi 定義，SAM 會為您建立此定義。

## 語法
<a name="sam-property-function-httpapi-syntax"></a>

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

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

```
  [ApiId](#sam-function-httpapi-apiid): String
  [Auth](#sam-function-httpapi-auth): HttpApiFunctionAuth
  [Method](#sam-function-httpapi-method): String
  [Path](#sam-function-httpapi-path): String
  [PayloadFormatVersion](#sam-function-httpapi-payloadformatversion): String
  [RouteSettings](#sam-function-httpapi-routesettings): [RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)
  [TimeoutInMillis](#sam-function-httpapi-timeoutinmillis): Integer
```

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

 `ApiId`   <a name="sam-function-httpapi-apiid"></a>
此範本中定義之[AWS::Serverless::HttpApi](sam-resource-httpapi.md)資源的識別符。  
如果未定義，則會`ServerlessHttpApi`使用產生的 OpenApi 文件來建立稱為 的預設[AWS::Serverless::HttpApi](sam-resource-httpapi.md)資源，其中包含由此範本中未指定 之 Api 事件所定義的所有路徑和方法的聯集`ApiId`。  
這無法參考另一個範本中定義的[AWS::Serverless::HttpApi](sam-resource-httpapi.md)資源。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Auth`   <a name="sam-function-httpapi-auth"></a>
此特定 Api\$1Path\$1Method 的驗證組態。  
用於在未指定 `DefaultAuthorizer` 時覆寫 API 的 `DefaultAuthorizer`或設定個別路徑上的身分驗證組態。  
*類型*：[HttpApiFunctionAuth](sam-property-function-httpapifunctionauth.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Method`   <a name="sam-function-httpapi-method"></a>
叫用此函數的 HTTP 方法。  
如果未指定 `Method` `Path`和 ，SAM 會建立預設 API 路徑，將任何未對應至不同端點的請求路由至此 Lambda 函數。每個 API 只能存在其中一個預設路徑。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Path`   <a name="sam-function-httpapi-path"></a>
叫用此函數的 Uri 路徑。必須以 開頭`/`。  
如果未指定 `Method` `Path`和 ，SAM 會建立預設 API 路徑，將任何未對應至不同端點的請求路由至此 Lambda 函數。每個 API 只能存在其中一個預設路徑。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `PayloadFormatVersion`   <a name="sam-function-httpapi-payloadformatversion"></a>
為傳送至整合的承載指定格式。  
注意：PayloadFormatVersion 需要 SAM 修改您的 OpenAPI 定義，因此僅適用於 `DefinitionBody` 屬性中定義的內嵌 OpenApi。  
*類型：*字串  
*必要*：否  
*預設*：2.0  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `RouteSettings`   <a name="sam-function-httpapi-routesettings"></a>
此 HTTP API 的每個路由路由設定。如需路由設定的詳細資訊，請參閱 *API Gateway 開發人員指南*中的 [AWS::ApiGatewayV2::Stage RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigatewayv2-stage-routesettings.html)。  
注意：如果在 HttpApi 資源和事件來源中都指定 RouteSettings， 會將它們與優先的事件來源屬性 AWS SAM 合併。  
*類型*：[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::ApiGatewayV2::Stage` 資源的 `[RouteSettings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigatewayv2-stage.html#cfn-apigatewayv2-stage-routesettings)` 屬性。

 `TimeoutInMillis`   <a name="sam-function-httpapi-timeoutinmillis"></a>
自訂介於 50 和 29,000 毫秒之間的逾時。  
注意：TimeoutInMillis 需要 SAM 修改您的 OpenAPI 定義，因此僅適用於 `DefinitionBody` 屬性中定義的內嵌 OpenApi。  
*類型*：整數  
*必要*：否  
*預設*：5000  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

## 範例
<a name="sam-property-function-httpapi--examples"></a>

### 預設 HttpApi 事件
<a name="sam-property-function-httpapi--examples--default-httpapi-event"></a>

使用預設路徑的 HttpApi 事件。此 API 上所有未映射的路徑和方法都會路由至此端點。

#### YAML
<a name="sam-property-function-httpapi--examples--default-httpapi-event--yaml"></a>

```
Events:
  HttpApiEvent:
    Type: HttpApi
```

### HttpApi
<a name="sam-property-function-httpapi--examples--httpapi"></a>

使用特定路徑和方法的 HttpApi 事件。

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

```
Events:
  HttpApiEvent:
    Type: HttpApi
    Properties:
      Path: /
      Method: GET
```

### HttpApi 授權
<a name="sam-property-function-httpapi--examples--httpapi-authorization"></a>

使用 授權方的 HttpApi 事件。

#### YAML
<a name="sam-property-function-httpapi--examples--httpapi-authorization--yaml"></a>

```
Events:
  HttpApiEvent:
    Type: HttpApi
    Properties:
      Path: /authenticated
      Method: GET
      Auth:
        Authorizer: OpenIdAuth
        AuthorizationScopes:
          - scope1
          - scope2
```

# HttpApiFunctionAuth
<a name="sam-property-function-httpapifunctionauth"></a>

在事件層級設定授權。

設定特定 API \$1 路徑 \$1 方法的驗證

## 語法
<a name="sam-property-function-httpapifunctionauth-syntax"></a>

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

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

```
  [AuthorizationScopes](#sam-function-httpapifunctionauth-authorizationscopes): List
  [Authorizer](#sam-function-httpapifunctionauth-authorizer): String
```

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

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

 `Authorizer`   <a name="sam-function-httpapifunctionauth-authorizer"></a>
特定函數`Authorizer`的 。若要使用 IAM 授權，請在範本的 `Globals`區段`EnableIamAuthorizer`中指定 `AWS_IAM`和 `true`的 。  
如果您已在 API 上指定全域授權方，並想要將特定函數設為公有，請將 `Authorizer`設定為 以覆寫 `NONE`。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-function-httpapifunctionauth--examples"></a>

### Function-Auth
<a name="sam-property-function-httpapifunctionauth--examples--function-auth"></a>

在函數層級指定授權

#### YAML
<a name="sam-property-function-httpapifunctionauth--examples--function-auth--yaml"></a>

```
Auth:
  Authorizer: OpenIdAuth
  AuthorizationScopes:
    - scope1
    - scope2
```

### IAM 授權
<a name="sam-property-function-httpapifunctionauth--examples--iam-authorization"></a>

在事件層級指定 IAM 授權。若要在事件層級使用`AWS_IAM`授權，您還必須在範本的 `Globals`區段`EnableIamAuthorizer`中指定 `true` 的 。如需詳細資訊，請參閱[AWS SAM 範本的全域區段](sam-specification-template-anatomy-globals.md)。

#### YAML
<a name="sam-property-function-httpapifunctionauth--examples--iam-authorization--yaml"></a>

```
Globals:
  HttpApi:
    Auth:
      EnableIamAuthorizer: true

Resources:
  HttpApiFunctionWithIamAuth:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        ApiEvent:
          Type: HttpApi
          Properties:
            Path: /iam-auth
            Method: GET
            Auth:
              Authorizer: AWS_IAM
      Handler: index.handler
      InlineCode: |
        def handler(event, context):
          return {'body': 'HttpApiFunctionWithIamAuth', 'statusCode': 200}
      Runtime: python3.9
```

# IoTRule
<a name="sam-property-function-iotrule"></a>

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

建立 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html) 資源以宣告 AWS IoT 規則。如需詳細資訊，請參閱 [CloudFormation 文件](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html)

## 語法
<a name="sam-property-function-iotrule-syntax"></a>

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

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

```
  [AwsIotSqlVersion](#sam-function-iotrule-awsiotsqlversion): String
  [Sql](#sam-function-iotrule-sql): String
```

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

 `AwsIotSqlVersion`   <a name="sam-function-iotrule-awsiotsqlversion"></a>
評估規則時所用的 SQL 規則引擎版本。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IoT::TopicRule TopicRulePayload` 資源的 `[AwsIotSqlVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iot-topicrule-topicrulepayload.html#cfn-iot-topicrule-topicrulepayload-awsiotsqlversion)` 屬性。

 `Sql`   <a name="sam-function-iotrule-sql"></a>
用於查詢主題的 SQL 陳述式。如需詳細資訊，請參閱《 *AWS IoT 開發人員指南*》中的 [AWS IoT SQL 參考](https://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html#aws-iot-sql-reference)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::IoT::TopicRule TopicRulePayload` 資源的 `[Sql](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iot-topicrule-topicrulepayload.html#cfn-iot-topicrule-topicrulepayload-sql)` 屬性。

## 範例
<a name="sam-property-function-iotrule--examples"></a>

### IOT 規則
<a name="sam-property-function-iotrule--examples--iot-rule"></a>

IOT 規則範例

#### YAML
<a name="sam-property-function-iotrule--examples--iot-rule--yaml"></a>

```
IoTRule:
  Type: IoTRule
  Properties:
    Sql: SELECT * FROM 'topic/test'
```

# Kinesis
<a name="sam-property-function-kinesis"></a>

描述`Kinesis`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon Kinesis](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html)。

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

## 語法
<a name="sam-property-function-kinesis-syntax"></a>

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

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

```
  [BatchSize](#sam-function-kinesis-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-kinesis-bisectbatchonfunctionerror): Boolean
  [DestinationConfig](#sam-function-kinesis-destinationconfig): [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)
  [Enabled](#sam-function-kinesis-enabled): Boolean
  [FilterCriteria](#sam-function-kinesis-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-kinesis-functionresponsetypes): List
  KmsKeyArn: String          
  [MaximumBatchingWindowInSeconds](#sam-function-kinesis-maximumbatchingwindowinseconds): Integer
  [MaximumRecordAgeInSeconds](#sam-function-kinesis-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-kinesis-maximumretryattempts): Integer
  [MetricsConfig](#sam-function-kinesis-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)
  [ParallelizationFactor](#sam-function-kinesis-parallelizationfactor): Integer
  [StartingPosition](#sam-function-kinesis-startingposition): String
  StartingPositionTimestamp: Double
  [Stream](#sam-function-kinesis-stream): String
  [TumblingWindowInSeconds](#sam-function-kinesis-tumblingwindowinseconds): Integer
```

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

 `BatchSize`   <a name="sam-function-kinesis-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `BisectBatchOnFunctionError`   <a name="sam-function-kinesis-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `DestinationConfig`   <a name="sam-function-kinesis-destinationconfig"></a>
捨棄記錄的 Amazon Simple Queue Service (Amazon SQS) 佇列或 Amazon Simple Notification Service (Amazon SNS) 主題目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)` 屬性。

 `Enabled`   <a name="sam-function-kinesis-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-kinesis-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-kinesis-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-batchfailurereporting)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-kinesis-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-kinesis-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-kinesis-maximumrecordageinseconds"></a>
Lambda 傳送給函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-kinesis-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `MetricsConfig`   <a name="sam-function-kinesis-metricsconfig"></a>
選擇加入組態，以取得擷取每個處理階段之事件來源映射的增強指標。如需範例，請參閱 [MetricsConfig 事件](sam-property-function-dynamodb.md#sam-property-function-dynamodb-example-metricsconfigevent)。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `ParallelizationFactor`   <a name="sam-function-kinesis-parallelizationfactor"></a>
要同時處理每個碎片的批次數量。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ParallelizationFactor](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-parallelizationfactor)` 屬性。

 `StartingPosition`   <a name="sam-function-kinesis-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-kinesis-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Stream`   <a name="sam-function-kinesis-stream"></a>
資料串流或串流消費者的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `TumblingWindowInSeconds`   <a name="sam-function-kinesis-tumblingwindowinseconds"></a>
處理時段的持續時間，以秒為單位。有效範圍為 1 到 900 (15 分鐘）。  
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[輪轉視窗](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#streams-tumbling)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[TumblingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-tumblingwindowinseconds)` 屬性。

## 範例
<a name="sam-property-function-kinesis--examples"></a>

### MetricsConfig 事件
<a name="sam-property-function-kinesis-example-metricsconfigevent"></a>

以下是 資源的範例，該資源使用 `MetricsConfig` 屬性來擷取其事件來源映射的每個處理階段。

```
Resources:
  FilteredEventsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/metricsConfig.zip
      Handler: index.handler
      Runtime: nodejs16.x
      Events:
        KinesisStream:
          Type: Kinesis
          Properties:
            Stream: !GetAtt KinesisStream.Arn
            StartingPosition: LATEST
            MetricsConfig:
              Metrics:
              - EventCount
```

### Kinesis 事件來源
<a name="sam-property-function-kinesis--examples--kinesis-event-source"></a>

以下是 Kinesis 事件來源的範例。

#### YAML
<a name="sam-property-function-kinesis--examples--kinesis-event-source--yaml"></a>

```
Events:
  KinesisEvent:
    Type: Kinesis
    Properties:
      Stream: arn:aws:kinesis:us-east-1:123456789012:stream/my-stream
      StartingPosition: TRIM_HORIZON
      BatchSize: 10
      Enabled: false
      FilterCriteria: 
        Filters: 
          - Pattern: '{"key": ["val1", "val2"]}'
```

# MQ
<a name="sam-property-function-mq"></a>

描述`MQ`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 Lambda 與 Amazon MQ](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html)。

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

**注意**  
若要在虛擬私有雲端 (VPC) 中擁有連線至公有網路中 Lambda 函數的 Amazon MQ 佇列，函數的執行角色必須包含下列許可：  
`ec2:CreateNetworkInterface`
`ec2:DeleteNetworkInterface`
`ec2:DescribeNetworkInterfaces`
`ec2:DescribeSecurityGroups`
`ec2:DescribeSubnets`
`ec2:DescribeVpcs`
如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[執行角色許可](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#events-mq-permissions)。

## 語法
<a name="sam-property-function-mq-syntax"></a>

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

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

```
  [BatchSize](#sam-function-mq-batchsize): Integer
  [Broker](#sam-function-mq-broker): String
  DynamicPolicyName: Boolean
  [Enabled](#sam-function-mq-enabled): Boolean
  [FilterCriteria](#sam-function-mq-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  KmsKeyArn: String 
  [MaximumBatchingWindowInSeconds](#sam-function-mq-maximumbatchingwindowinseconds): Integer
  [Queues](#sam-function-mq-queues): List
  [SecretsManagerKmsKeyId](#sam-function-mq-secretsmanagerkmskeyid): String
  [SourceAccessConfigurations](#sam-function-mq-sourceaccessconfigurations): List
```

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

 `BatchSize`   <a name="sam-function-mq-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `Broker`   <a name="sam-function-mq-broker"></a>
Amazon MQ 代理程式的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `DynamicPolicyName`   <a name="sam-function-mq-dynamicpolicyname"></a>
根據預設， AWS Identity and Access Management (IAM) 政策名稱`SamAutoGeneratedAMQPolicy`用於回溯相容性。指定 `true` 為您的 IAM 政策使用自動產生的名稱。此名稱將包含 Amazon MQ 事件來源邏輯 ID。  
使用多個 Amazon MQ 事件來源時，請指定 `true`以避免重複的 IAM 政策名稱。
*類型*：布林值  
*必要*：否  
*預設*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `Enabled`   <a name="sam-function-mq-enabled"></a>
如果為 `true`，則事件來源映射為作用中。若要暫停輪詢和調用，請將 設定為 `false`。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-mq-filtercriteria"></a>
定義決定 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `KmsKeyArn`   <a name="sam-function-mq-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-mq-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `Queues`   <a name="sam-function-mq-queues"></a>
要使用的 Amazon MQ 代理程式目的地佇列的名稱。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Queues](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-queues)` 屬性。

 `SecretsManagerKmsKeyId`   <a name="sam-function-mq-secretsmanagerkmskeyid"></a>
客戶受管金鑰的 AWS Key Management Service (AWS KMS) 金鑰 ID AWS Secrets Manager。當您使用來自 Secrets Manager 的客戶受管金鑰搭配不包含 `kms:Decrypt`許可的 Lambda 執行角色時，此為必要項目。  
此屬性的值是 UUID。例如：`1abc23d4-567f-8ab9-cde0-1fab234c5d67`。  
*類型：*字串  
*必要*：有條件  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `SourceAccessConfigurations`   <a name="sam-function-mq-sourceaccessconfigurations"></a>
身分驗證通訊協定或虛擬主機的陣列。使用 [SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) 資料類型指定此項目。  
對於`MQ`事件來源類型，唯一有效的組態類型是 `BASIC_AUTH`和 `VIRTUAL_HOST`。  
+ **`BASIC_AUTH`** – 存放代理程式登入資料的 Secrets Manager 秘密。對於此類型，登入資料必須採用下列格式：`{"username": "your-username", "password": "your-password"}`。僅允許一個 類型的物件`BASIC_AUTH`。
+ **`VIRTUAL_HOST`** – RabbitMQ 代理程式中的虛擬主機名稱。Lambda 會使用此 Rabbit MQ 的主機做為事件來源。僅允許一個 類型的物件`VIRTUAL_HOST`。
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)` 屬性。

## 範例
<a name="sam-property-function-mq--examples"></a>

### Amazon MQ 事件來源
<a name="sam-property-function-mq--examples--amazon-mq-event-source"></a>

以下是 Amazon MQ 代理程式`MQ`的事件來源類型範例。

#### YAML
<a name="sam-property-function-mq--examples--amazon-mq-event-source--yaml"></a>

```
Events:
  MQEvent:
    Type: MQ
    Properties:
      Broker: arn:aws:mq:us-east-2:123456789012:broker:MyBroker:b-1234a5b6-78cd-901e-2fgh-3i45j6k178l9
      Queues: List of queues
      SourceAccessConfigurations:
        - Type: BASIC_AUTH
          URI: arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName
      BatchSize: 200
      Enabled: true
```

# MSK
<a name="sam-property-function-msk"></a>

描述`MSK`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon MSK](https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html)。

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

若要使用結構描述登錄檔，您需要定義函數的特定 IAM 角色許可。如需所需組態的範例，請參閱[使用 IAM 角色完成設定](#sam-property-function-msk-example-complete)。

## 語法
<a name="sam-property-function-msk-syntax"></a>

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

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

```
  [BatchSize](#sam-function-msk-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-msk-bisectbatchonfunctionerror): Boolean
  [ConsumerGroupId](#sam-function-msk-consumergroupid): String
  DestinationConfig: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)
  [Enabled](#sam-function-msk-enabled): Boolean
  [FilterCriteria](#sam-function-msk-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-msk-functionresponsetypes): List
  KmsKeyArn: String
  [MaximumBatchingWindowInSeconds](#sam-function-msk-maximumbatchingwindowinseconds): Integer
  [MaximumRecordAgeInSeconds](#sam-function-msk-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-msk-maximumretryattempts): Integer
  [LoggingConfig](#sam-function-msk-loggingconfig): [LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html)
  [MetricsConfig](#sam-function-msk-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html)
  [ProvisionedPollerConfig](#sam-function-msk-provisionedpollerconfig): [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)
  [SchemaRegistryConfig](#sam-function-msk-schemaregistryconfig): [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html)
  SourceAccessConfigurations: [SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)
  [StartingPosition](#sam-function-msk-startingposition): String
  StartingPositionTimestamp: Double
  [Stream](#sam-function-msk-stream): String
  [Topics](#sam-function-msk-topics): List
```

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

 `BatchSize`   <a name="sam-function-msk-batchsize"></a>
Lambda 從串流或佇列中提取並傳送至函數的每個批次中的記錄數目上限。Lambda 會將批次中的所有記錄以單一呼叫形式傳送至函數，直到達到同步調用的承載限制 (6 MB)。  
*預設值*：100  
*有效範圍*：最小值為 1。最大值為 10，000。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。

 `BisectBatchOnFunctionError`   <a name="sam-function-msk-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `ConsumerGroupId`   <a name="sam-function-msk-consumergroupid"></a>
設定如何從 Kafka 主題讀取事件的字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[AmazonManagedKafkaConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html)` 屬性。

 `DestinationConfig`   <a name="sam-function-msk-destinationconfig"></a>
組態物件，指定在 Lambda 處理過後事件的目標。  
使用此屬性可指定來自 Amazon MSK 事件來源的失敗調用目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)` 屬性。

 `Enabled`   <a name="sam-function-msk-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-msk-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-msk-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/kafka-retry-configurations.html)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-msk-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-msk-maximumbatchingwindowinseconds"></a>
調用函式前收集記錄的最長時間 (單位為秒)。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-msk-maximumrecordageinseconds"></a>
Lambda 傳送給函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-msk-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `LoggingConfig`   <a name="sam-function-msk-loggingconfig"></a>
組態物件，指定事件來源映射的記錄組態。  
*類型*︰[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig.html)` 屬性。

 `MetricsConfig`   <a name="sam-function-msk-metricsconfig"></a>
組態物件，指定事件來源映射的指標組態。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig.html)` 屬性。

 `ProvisionedPollerConfig`   <a name="sam-function-msk-provisionedpollerconfig"></a>
用於增加用於計算事件來源映射之輪詢器數量的組態。此組態允許最少 1 個輪詢器，最多 2000 個輪詢器。如需範例，請參閱 [ProvisionedPollerConfig 範例](#sam-property-function-msk-example-provisionedpollerconfig)。  
*類型*：[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)` 屬性。

`SchemaRegistryConfig`  <a name="sam-function-msk-schemaregistryconfig"></a>
搭配 Kafka 事件來源使用結構描述登錄檔的組態。  
此功能`ProvisionedPollerConfig`需要設定。
*類型*： SchemaRegistryConfig  
*必要*：否  
*CloudFormation 相容性：*此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[AmazonManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-amazonmanagedkafkaeventsourceconfig)` 屬性。

 `SourceAccessConfigurations`   <a name="sam-function-msk-sourceaccessconfigurations"></a>
保護和定義事件來源的身分驗證協定、VPC 元件或虛擬主機。  
*有效值*：`CLIENT_CERTIFICATE_TLS_AUTH`  
*類型*：[SourceAccessConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) 清單  
*必要*：否  
*CloudFormation 相容性：*此屬性是 `AWS::Lambda::EventSourceMapping` 資源的 [AmazonManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-lambda-eventsourcemapping-amazonmanagedkafkaeventsourceconfig) 屬性的一部分。

 `StartingPosition`   <a name="sam-function-msk-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-msk-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Stream`   <a name="sam-function-msk-stream"></a>
資料串流或串流取用者的 Amazon Resource Name (ARN)。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `Topics`   <a name="sam-function-msk-topics"></a>
Kafka 主題名稱。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Topics](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-topics)` 屬性。

## 範例
<a name="sam-property-function-msk--examples"></a>

### 使用 IAM 角色完成設定
<a name="sam-property-function-msk-example-complete"></a>

下列範例顯示完整的設定，包括使用結構描述登錄所需的 IAM 角色組態：

```
Parameters:
  PreCreatedSubnetOne:
    Type: String
  PreCreatedSubnetTwo:
    Type: String
  MskClusterName4:
    Type: String

Resources:
  MyLambdaExecutionRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17		 	 	 '
        Statement:
        - Action: [sts:AssumeRole]
          Effect: Allow
          Principal:
            Service: [lambda.amazonaws.com]
      Policies:
      - PolicyName: KafkaClusterPermissions
        PolicyDocument:
          Statement:
          - Action: [kafka:DescribeClusterV2, kafka:GetBootstrapBrokers]
            Effect: Allow
            Resource: 'arn:aws:kafka:us-east-1:123456789012:cluster/*'
      - PolicyName: KafkaAuthPolicy
        PolicyDocument:
          Statement:
          - Action: [secretsmanager:GetSecretValue, kms:Decrypt]
            Effect: "Allow"
            Resource: ['arn:aws:secretsmanager:us-west-2:123456789012:secret:kafkaSecret-******',
                        'arn:aws:kms:us-west-2:123456789012:key/keyId']
      - PolicyName: ENIPolicy
        PolicyDocument:
          Statement:
          - Action: [ec2:CreateNetworkInterface,
              ec2:DescribeNetworkInterfaces, ec2:DescribeVpcs, ec2:DeleteNetworkInterface,
              ec2:DescribeSubnets, ec2:DescribeSecurityGroups]
            Effect: Allow
            Resource: '*'
      - PolicyName: SchemaRegistryPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetRegistry]
            Effect: Allow
            Resource: 'arn:aws:glue:{region}:{account-id}:registry/{registry-name}'
      - PolicyName: SchemaVersionsPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetSchemaVersions]
            Effect: Allow
            Resource: '*'
      ManagedPolicyArns:
      - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Tags:
      - {Value: SAM, Key: lambda:createdBy}

  MyMskCluster:
    Type: AWS::MSK::Cluster
    Properties:
      BrokerNodeGroupInfo:
        ClientSubnets:
        - Ref: PreCreatedSubnetOne
        - Ref: PreCreatedSubnetTwo
        InstanceType: kafka.t3.small
        StorageInfo:
          EBSStorageInfo:
            VolumeSize: 1
      ClusterName:
        Ref: MskClusterName4
      KafkaVersion: 3.8.x
      NumberOfBrokerNodes: 2

  MyMskStreamProcessor:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: nodejs18.x
      Handler: index.handler
      CodeUri: ${codeuri}
      Role:
        Fn::GetAtt: [MyLambdaExecutionRole, Arn]
      Events:
        MyMskEvent:
          Type: MSK
          Properties:
            StartingPosition: LATEST
            Stream:
              Ref: MyMskCluster
            SourceAccessConfigurations:
            - Type: SASL_SCRAM_512_AUTH
              URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
            Topics:
            - SchemaRegistryTestTopic
            ProvisionedPollerConfig:
              MinimumPollers: 1
            SchemaRegistryConfig:
              AccessConfigs:
              - Type: BASIC_AUTH
                URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
              SchemaValidationConfigs:
              - Attribute: KEY
              EventRecordFormat: JSON
              SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
```

### ProvisionedPollerConfig 範例
<a name="sam-property-function-msk-example-provisionedpollerconfig"></a>

```
ProvisionedPollerConfig:
  MinimumPollers: 1
  MaximumPollers: 200
```

### 現有叢集的 Amazon MSK 範例
<a name="sam-property-function-msk--examples--amazon-msk-example-for-existing-cluster"></a>

以下是已存在於 之 Amazon MSK 叢集`MSK`的事件來源類型範例 AWS 帳戶。

#### YAML
<a name="sam-property-function-msk--examples--amazon-msk-example-for-existing-cluster--yaml"></a>

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream: arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2
      Topics:
        - MyTopic
```

### 相同範本中宣告之叢集的 Amazon MSK 範例
<a name="sam-property-function-msk--examples--amazon-msk-example-for-cluster-declared-in-same-template"></a>

以下是在相同範本檔案中宣告之 Amazon MSK 叢集`MSK`的事件來源類型範例。

#### YAML
<a name="sam-property-function-msk--examples--amazon-msk-example-for-cluster-declared-in-same-template--yaml"></a>

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream:
        Ref: MyMskCluster   # This must be the name of an MSK cluster declared in the same template file
      Topics:
        - MyTopic
```

#### 具有結構描述登錄檔的 MSK 事件來源
<a name="sam-property-function-msk-example-schemaregistry"></a>

以下是使用結構描述登錄檔設定`MSK`的事件來源類型範例。

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream:
        Ref: MyMskCluster
      Topics:
        - SchemaRegistryTestTopic
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
```

#### 具有 Confluent 結構描述登錄檔的 MSK 事件來源
<a name="sam-property-function-msk-example-schemaregistry-confluent"></a>

以下是使用 Confluent 結構描述登錄檔設定`MSK`的事件來源類型範例。

```
Events:
  MSKEvent:
    Type: MSK
    Properties:
      StartingPosition: LATEST
      Stream:
        Ref: MyMskCluster
      Topics:
        - SchemaRegistryTestTopic
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: https://my-schema-registry.confluent.cloud
        AccessConfigs:
          - Type: BASIC_AUTH
            URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-secret
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
```

# S3
<a name="sam-property-function-s3"></a>

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

## 語法
<a name="sam-property-function-s3-syntax"></a>

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

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

```
  [Bucket](#sam-function-s3-bucket): String
  [Events](#sam-function-s3-events): String | List
  [Filter](#sam-function-s3-filter): [NotificationFilter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)
```

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

 `Bucket`   <a name="sam-function-s3-bucket"></a>
S3 儲存貯體名稱。此儲存貯體必須存在於相同的範本中。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性類似於 `AWS::S3::Bucket` 資源的 `[BucketName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html#cfn-s3-bucket-name)` 屬性。這是 SAM 中的必要欄位。此欄位僅接受在此範本中建立之 S3 儲存貯體的參考

 `Events`   <a name="sam-function-s3-events"></a>
要叫用 Lambda 函數的 Amazon S3 儲存貯體事件。如需有效值的清單，請參閱 [Amazon S3 支援的事件類型](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types)。  
*類型*：字串 \$1 清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::S3::Bucket` `LambdaConfiguration` 資料類型的 `[Event](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig-lambdaconfig.html#cfn-s3-bucket-notificationconfig-lambdaconfig-event)` 屬性。

 `Filter`   <a name="sam-function-s3-filter"></a>
篩選規則，決定哪些 Amazon S3 物件叫用 Lambda 函數。如需 Amazon S3 金鑰名稱篩選的相關資訊，請參閱[《Amazon Simple Storage Service 使用者指南》中的設定 Amazon S3 事件通知](https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html)。 **  
*類型*：[NotificationFilter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::S3::Bucket` `LambdaConfiguration` 資料類型的 `[Filter](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html)` 屬性。

## 範例
<a name="sam-property-function-s3--examples"></a>

### S3-Event
<a name="sam-property-function-s3--examples--s3-event"></a>

S3 事件的範例。

#### YAML
<a name="sam-property-function-s3--examples--s3-event--yaml"></a>

```
Events:
  S3Event:
    Type: S3
    Properties:
      Bucket:
        Ref: ImagesBucket     # This must be the name of an S3 bucket declared in the same template file
      Events: s3:ObjectCreated:*
      Filter:
        S3Key:
          Rules:
          - Name: prefix      # or "suffix"
            Value: value      # The value to search for in the S3 object key names
```

# Schedule
<a name="sam-property-function-schedule"></a>

描述`Schedule`事件來源類型的物件，會將無伺服器函數設定為排程觸發的 Amazon 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) 資源。

**注意**  
EventBridge 現在提供新的排程功能：[Amazon EventBridge。 Scheduler](https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html)Amazon EventBridge Scheduler 是一種無伺服器排程器，可讓您從一個集中的受管服務建立、執行和管理任務。EventBridge Scheduler 可高度自訂，並提供比 EventBridge 排程規則更佳的可擴展性，具有更廣泛的目標 API 操作集和 AWS 服務。  
我們建議您使用 EventBridge 排程Scheduler叫用目標。若要在 AWS SAM 範本中定義此事件來源類型，請參閱 [ScheduleV2](sam-property-function-schedulev2.md)。

## 語法
<a name="sam-property-function-schedule-syntax"></a>

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

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

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

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

 `DeadLetterConfig`   <a name="sam-function-schedule-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)。  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型 `DeadLetterQueue`，可處理成功叫用目標 Lambda 函數後發生的失敗。這些失敗類型的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。
*類型*：[DeadLetterConfig](sam-property-function-scheduledeadletterconfig.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-function-schedule-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-function-schedule-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-function-schedule-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-function-schedule-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-function-schedule-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)` 屬性。

 `Schedule`   <a name="sam-function-schedule-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-function-schedule-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)` 屬性。

## 範例
<a name="sam-property-function-schedule--examples"></a>

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

CloudWatch 排程事件範例

#### YAML
<a name="sam-property-function-schedule--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-function-scheduledeadletterconfig"></a>

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

**注意**  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型，`DeadLetterQueue`可處理成功調用目標 Lambda 函數後發生的失敗。此類故障的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。

## 語法
<a name="sam-property-function-scheduledeadletterconfig-syntax"></a>

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

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

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

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

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

 `Type`   <a name="sam-function-scheduledeadletterconfig-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-function-scheduledeadletterconfig--examples"></a>

### DeadLetterConfig
<a name="sam-property-function-scheduledeadletterconfig--examples--deadletterconfig"></a>

DeadLetterConfig

#### YAML
<a name="sam-property-function-scheduledeadletterconfig--examples--deadletterconfig--yaml"></a>

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

# ScheduleV2
<a name="sam-property-function-schedulev2"></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-function-schedulev2-syntax"></a>

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

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

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

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

 `DeadLetterConfig`   <a name="sam-function-schedulev2-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 *  
[AWS::Serverless::Function](sam-resource-function.md) 資源類型具有類似的資料類型 `DeadLetterQueue`，可處理成功調用目標 Lambda 函數後發生的失敗。這些失敗類型的範例包括 Lambda 限流，或 Lambda 目標函數傳回的錯誤。如需 函數`DeadLetterQueue`屬性的詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[無效字母佇列](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#invocation-dlq)。
*類型*：[DeadLetterConfig](sam-property-function-scheduledeadletterconfig.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-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-schedule.html#cfn-scheduler-schedule-flexibletimewindow)` 屬性。

 `GroupName`   <a name="sam-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-function-schedulev2-name"></a>
排程的名稱。如果您未指定名稱， 會以 格式 AWS SAM 產生名稱`Function-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-function-schedulev2-omitname"></a>
根據預設， AWS SAM 會產生並使用 *<Function-logical-ID><event-source-name>* 格式的排程名稱。將此屬性設定為 `true`，讓 CloudFormation 產生唯一的實體 ID，並改為將該 ID 用於排程名稱。  
*類型*：布林值  
*必要*：否  
*預設*：`false`  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有同等 CloudFormation 的。

 `PermissionsBoundary`   <a name="sam-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-function-schedulev2-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-function-schedulev2--examples"></a>

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

```
Resources:
  Function:
    Properties:
      ...
      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
```

**注意**  
ScheduleV2 產生的實體 ID 不包含堆疊名稱。

# SelfManagedKafka
<a name="sam-property-function-selfmanagedkafka"></a>

描述`SelfManagedKafka`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[使用 AWS Lambda 搭配自我管理的 Apache Kafka](https://docs.aws.amazon.com/lambda/latest/dg/with-kafka.html)。

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

若要使用結構描述登錄檔，您需要定義函數的特定 IAM 角色許可。如需所需組態的範例，請參閱[使用 IAM 角色完成設定](sam-property-function-msk.md#sam-property-function-msk-example-complete)。

## 語法
<a name="sam-property-function-selfmanagedkafka-syntax"></a>

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

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

```
  [BatchSize](#sam-function-selfmanagedkafka-batchsize): Integer
  [BisectBatchOnFunctionError](#sam-function-selfmanagedkafka-bisectbatchonfunctionerror): Boolean
  [ConsumerGroupId](#sam-function-selfmanagedkafka-consumergroupid): String
  DestinationConfig: [DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)
  [Enabled](#sam-function-selfmanagedkafka-enabled): Boolean
  [FilterCriteria](#sam-function-selfmanagedkafka-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [KafkaBootstrapServers](#sam-function-selfmanagedkafka-kafkabootstrapservers): List
  [FunctionResponseTypes](#sam-function-selfmanagedkafka-functionresponsetypes): List
  KmsKeyArn: String
  [LoggingConfig](#sam-function-selfmanagedkafka-loggingconfig): LoggingConfig
  [MaximumRecordAgeInSeconds](#sam-function-selfmanagedkafka-maximumrecordageinseconds): Integer
  [MaximumRetryAttempts](#sam-function-selfmanagedkafka-maximumretryattempts): Integer
  [MetricsConfig](#sam-function-selfmanagedkafka-metricsconfig): MetricsConfig
  [ProvisionedPollerConfig](#sam-function-selfmanagedkafka-provisionedpollerconfig): [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)
  [SchemaRegistryConfig](#sam-function-selfmanagedkafka-schemaregistryconfig): [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig.html)
  [SourceAccessConfigurations](#sam-function-selfmanagedkafka-sourceaccessconfigurations): [SourceAccessConfigurations](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-sourceaccessconfigurations)
  StartingPosition: String
  StartingPositionTimestamp: Double
  [Topics](#sam-function-selfmanagedkafka-topics): List
```

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

 `BatchSize`   <a name="sam-function-selfmanagedkafka-batchsize"></a>
Lambda 從串流提取並傳送至函數的每個批次中的記錄數目上限。  
*類型*：整數  
*必要*：否  
*預設值*：100  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `BisectBatchOnFunctionError`   <a name="sam-function-selfmanagedkafka-bisectbatchonfunctionerror"></a>
如果函數傳回錯誤，請將批次分割為兩個，然後重試。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BisectBatchOnFunctionError](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror)` 屬性。

 `ConsumerGroupId`   <a name="sam-function-selfmanagedkafka-consumergroupid"></a>
設定如何從 Kafka 主題讀取事件的字串。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[SelfManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig)` 屬性。

 `DestinationConfig`   <a name="sam-function-selfmanagedkafka-destinationconfig"></a>
組態物件，指定在 Lambda 處理過後事件的目標。  
使用此屬性可指定從自我管理 Kafka 事件來源呼叫失敗的目的地。  
*類型*：[DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-destinationconfig.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ DestinationConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig)` 屬性。

 `Enabled`   <a name="sam-function-selfmanagedkafka-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-selfmanagedkafka-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-filtercriteria)` 屬性。

 `KafkaBootstrapServers`   <a name="sam-function-selfmanagedkafka-kafkabootstrapservers"></a>
Kafka 代理程式的引導伺服器清單。包含連接埠，例如 `broker.example.com:xxxx`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `FunctionResponseTypes`   <a name="sam-function-selfmanagedkafka-functionresponsetypes"></a>
目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《AWS Lambda 開發人員指南》**中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/kafka-retry-configurations.html)。  
*有效值*：`ReportBatchItemFailures`  
*類型：*清單  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-selfmanagedkafka-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `LoggingConfig`   <a name="sam-function-selfmanagedkafka-loggingconfig"></a>
事件來源的記錄組態。  
*類型*︰[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-loggingconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[LoggingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-loggingconfig)` 屬性。

 `MaximumRecordAgeInSeconds`   <a name="sam-function-selfmanagedkafka-maximumrecordageinseconds"></a>
Lambda 傳送至函數進行處理的記錄最長存留期。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRecordAgeInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds)` 屬性。

 `MetricsConfig`   <a name="sam-function-selfmanagedkafka-metricsconfig"></a>
事件來源的指標組態。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `MaximumRetryAttempts`   <a name="sam-function-selfmanagedkafka-maximumretryattempts"></a>
當函數傳回錯誤時，重試的次數上限。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumRetryAttempts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts)` 屬性。

 `ProvisionedPollerConfig`   <a name="sam-function-selfmanagedkafka-provisionedpollerconfig"></a>
用於增加用於計算事件來源映射之輪詢器數量的組態。此組態允許最少 1 個輪詢器，最多 2000 個輪詢器。如需範例，請參閱 [ProvisionedPollerConfig 範例](#sam-property-function-selfmanagedkafka-example-provisionedpollerconfig)  
*類型*：[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-provisionedpollerconfig)` 屬性。

`SchemaRegistryConfig`  <a name="sam-function-selfmanagedkafka-schemaregistryconfig"></a>
搭配自我管理 Kafka 事件來源使用結構描述登錄檔的組態。  
此功能`ProvisionedPollerConfig`需要設定。
*類型*： [SchemaRegistryConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-schemaregistryconfig)  
*必要*：否  
*CloudFormation 相容性：*此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[SelfManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig)` 屬性。

 `SourceAccessConfigurations`   <a name="sam-function-selfmanagedkafka-sourceaccessconfigurations"></a>
保護和定義事件來源的身分驗證協定、VPC 元件或虛擬主機。  
*有效值*：`BASIC_AUTH | CLIENT_CERTIFICATE_TLS_AUTH | SASL_SCRAM_256_AUTH | SASL_SCRAM_512_AUTH | SERVER_ROOT_CA_CERTIFICATE`  
*類型*：[SourceAccessConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration) 清單  
*必要*：是  
*CloudFormation 相容性：*此屬性是 `AWS::Lambda::EventSourceMapping` 資源的 `[SelfManagedKafkaEventSourceConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig)` 屬性的一部分。

 `StartingPosition`   <a name="sam-function-selfmanagedkafka-startingposition"></a>
要從中開始讀取的串流位置。  
+ `AT_TIMESTAMP` – 指定從中開始讀取記錄的時間。
+ `LATEST` – 唯讀新記錄。
+ `TRIM_HORIZON` – 處理所有可用的記錄。
*有效值*：`AT_TIMESTAMP` \$1 `LATEST` \$1 `TRIM_HORIZON`  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPosition](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition)` 屬性。

 `StartingPositionTimestamp`   <a name="sam-function-selfmanagedkafka-startingpositiontimestamp"></a>
開始讀取的時間，以 Unix 時間秒為單位。定義 `StartingPositionTimestamp` `StartingPosition` 何時指定為 `AT_TIMESTAMP`。  
*類型*：Double  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[StartingPositionTimestamp](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingpositiontimestamp)` 屬性。

 `Topics`   <a name="sam-function-selfmanagedkafka-topics"></a>
Kafka 主題名稱。  
*類型：*清單  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Topics](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-topics)` 屬性。

## 範例
<a name="sam-property-function-selfmanagedkafka--examples"></a>

### 使用 IAM 角色完成設定
<a name="sam-property-function-selfmanagedkafka-example-complete"></a>

下列範例顯示完整的設定，包括使用結構描述登錄所需的 IAM 角色組態：

```
Parameters:
  PreCreatedSubnetOne:
    Type: String
  PreCreatedSubnetTwo:
    Type: String

Resources:
  MyLambdaExecutionRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17		 	 	 '
        Statement:
        - Action: [sts:AssumeRole]
          Effect: Allow
          Principal:
            Service: [lambda.amazonaws.com]
      Policies:
      - PolicyName: KafkaAuthPolicy
        PolicyDocument:
          Statement:
          - Action: [secretsmanager:GetSecretValue, kms:Decrypt]
            Effect: "Allow"
            Resource: ['arn:aws:secretsmanager:us-west-2:123456789012:secret:kafkaSecret-******',
                        'arn:aws:kms:us-west-2:123456789012:key/keyId']
      - PolicyName: ENIPolicy
        PolicyDocument:
          Statement:
          - Action: [ec2:CreateNetworkInterface,
              ec2:DescribeNetworkInterfaces, ec2:DescribeVpcs, ec2:DeleteNetworkInterface,
              ec2:DescribeSubnets, ec2:DescribeSecurityGroups]
            Effect: Allow
            Resource: '*'
      - PolicyName: SchemaRegistryPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetRegistry]
            Effect: Allow
            Resource: 'arn:aws:glue:{region}:{account-id}:registry/{registry-name}'
      - PolicyName: SchemaVersionsPolicy
        PolicyDocument:
          Statement:
          - Action: [glue:GetSchemaVersions]
            Effect: Allow
            Resource: '*'
      ManagedPolicyArns:
      - !Sub arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Tags:
      - {Value: SAM, Key: lambda:createdBy}

  MyKafkaProcessor:
    Type: AWS::Serverless::Function
    Properties:
      Runtime: nodejs18.x
      Handler: index.handler
      CodeUri: ${codeuri}
      Role:
        Fn::GetAtt: [MyLambdaExecutionRole, Arn]
      Events:
        SelfManagedKafkaEvent:
          Type: SelfManagedKafka
          Properties:
            KafkaBootstrapServers:
              - my-kafka-broker-1:9092
              - my-kafka-broker-2:9092
            Topics:
              - SchemaRegistryTestTopic
            StartingPosition: LATEST
            SourceAccessConfigurations:
              - Type: VPC_SUBNET
                URI: subnet:subnet-12345678
              - Type: VPC_SECURITY_GROUP
                URI: security_group:sg-12345678
              - Type: BASIC_AUTH
                URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
            ProvisionedPollerConfig:
              MinimumPollers: 1
            SchemaRegistryConfig:
              AccessConfigs:
              - Type: BASIC_AUTH
                URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
              SchemaValidationConfigs:
              - Attribute: KEY
              EventRecordFormat: JSON
              SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
```

### ProvisionedPollerConfig 範例
<a name="sam-property-function-selfmanagedkafka-example-provisionedpollerconfig"></a>

```
ProvisionedPollerConfig:
  MinimumPollers: 1
  MaximumPollers: 200
```

### 自我管理的 Kafka 事件來源
<a name="sam-property-function-selfmanagedkafka--examples--self-managed-kafka-event-source"></a>

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

#### YAML
<a name="sam-property-function-selfmanagedkafka--examples--self-managed-kafka-event-source--yaml"></a>

```
Events:
  SelfManagedKafkaEvent:
    Type: SelfManagedKafka
    Properties:
      BatchSize: 1000
      Enabled: true
      KafkaBootstrapServers:
        - abc.xyz.com:xxxx
      SourceAccessConfigurations:
        -  Type: BASIC_AUTH
           URI: arn:aws:secretsmanager:us-west-2:123456789012:secret:my-path/my-secret-name-1a2b3c
      Topics:
        - MyKafkaTopic
```

### 具有 AWS Glue 結構描述登錄檔的自我管理 Kafka 事件來源
<a name="sam-property-function-selfmanagedkafka-example-schemaregistry"></a>

以下是使用 AWS Glue 結構描述登錄檔設定`SelfManagedKafka`的事件來源類型範例。

```
Events:
  SelfManagedKafkaEvent:
    Type: SelfManagedKafka
    Properties:
      KafkaBootstrapServers:
        - abc.xyz.com:9092
      Topics:
        - SchemaRegistryTestTopic
      StartingPosition: LATEST
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: !Sub arn:${AWS::Partition}:glue:us-west-2:123456789012:registry/myregistry
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
      SourceAccessConfigurations:
        - Type: VPC_SUBNET
          URI: subnet:subnet-12345678
        - Type: VPC_SECURITY_GROUP
          URI: security_group:sg-12345678
```

### 具有 Confluent Schema Registry 的自我管理 Kafka 事件來源
<a name="sam-property-function-selfmanagedkafka-example-schemaregistry-confluent"></a>

以下是使用 Confluent Schema Registry 設定`SelfManagedKafka`的事件來源類型範例。

```
Events:
  SelfManagedKafkaEvent:
    Type: SelfManagedKafka
    Properties:
      KafkaBootstrapServers:
        - abc.xyz.com:9092
      Topics:
        - SchemaRegistryTestTopic
      StartingPosition: LATEST
      ProvisionedPollerConfig:
        MinimumPollers: 1
      SchemaRegistryConfig:
        SchemaRegistryURI: https://my-schema-registry.confluent.cloud
        AccessConfigs:
          - Type: BASIC_AUTH
            URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:my-secret
        EventRecordFormat: JSON
        SchemaValidationConfigs:
          - Attribute: KEY
          - Attribute: VALUE
      SourceAccessConfigurations:
        - Type: VPC_SUBNET
          URI: subnet:subnet-12345678
        - Type: VPC_SECURITY_GROUP
          URI: security_group:sg-12345678
        - Type: BASIC_AUTH
          URI: !Sub arn:${AWS::Partition}:secretsmanager:us-west-2:123456789012:secret:kafka-secret
```

# SNS
<a name="sam-property-function-sns"></a>

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

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

## 語法
<a name="sam-property-function-sns-syntax"></a>

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

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

```
  [FilterPolicy](#sam-function-sns-filterpolicy): [SnsFilterPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy)
  FilterPolicyScope: String
  RedrivePolicy: Json
  [Region](#sam-function-sns-region): String
  [SqsSubscription](#sam-function-sns-sqssubscription): Boolean | SqsSubscriptionObject
  [Topic](#sam-function-sns-topic): String
```

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

 `FilterPolicy`   <a name="sam-function-sns-filterpolicy"></a>
指派給訂閱的篩選條件政策 JSON。如需詳細資訊，請參閱《Amazon Simple Notification Service API 參考》中的 [GetSubscriptionAttributes](https://docs.aws.amazon.com/sns/latest/api/API_GetSubscriptionAttributes.html)。  
*類型*：[SnsFilterPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[FilterPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicy)` 屬性。

 `FilterPolicyScope`   <a name="sam-function-sns-filterpolicyscope"></a>
此屬性可讓您使用下列其中一個字串值類型來選擇篩選範圍：  
+ `MessageAttributes` – 篩選條件會套用至訊息屬性。
+ `MessageBody` – 篩選條件會套用至訊息內文。
*類型：*字串  
*必要*：否  
*預設*：`MessageAttributes`  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 ` [ FilterPolicyScope](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-filterpolicyscope)` 屬性。

 `RedrivePolicy`   <a name="sam-function-sns-redrivepolicy"></a>
如果指定，則會將無法傳遞的訊息傳送到指定的 Amazon SQS 無效信件佇列。由於用戶端錯誤 (例如當訂閱的端點無法連線時) 或伺服器錯誤 (例如提供訂閱端點的服務無法使用) 而無法傳遞的訊息，會保留在無效信件佇列，以供進一步分析或重新處理。  
如需再驅動政策和無效字母佇列的詳細資訊，請參閱[《Amazon Simple Queue Service 開發人員指南》中的 Amazon SQS 無效字母佇列](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html)。 **  
*類型*：Json  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[ RedrivePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-redrivepolicy)` 屬性。

 `Region`   <a name="sam-function-sns-region"></a>
針對跨區域訂閱，為主題所在的區域。  
如果未指定區域，CloudFormation 會使用發起人的區域做為預設值。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[Region](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#cfn-sns-subscription-region)` 屬性。

 `SqsSubscription`   <a name="sam-function-sns-sqssubscription"></a>
將此屬性設定為 true，或指定 `SqsSubscriptionObject` 在 SQS 佇列中啟用批次 SNS 主題通知。將此屬性設定為`true`建立新的 SQS 佇列，而指定 `SqsSubscriptionObject`會使用現有的 SQS 佇列。  
*類型*：布林值 \$1 [SqsSubscriptionObject](sam-property-function-sqssubscriptionobject.md)  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Topic`   <a name="sam-function-sns-topic"></a>
要訂閱的主題 ARN。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::SNS::Subscription` 資源的 `[TopicArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#topicarn)` 屬性。

## 範例
<a name="sam-property-function-sns--examples"></a>

### SNS 事件來源範例
<a name="sam-property-function-sns--examples--sns-event-source-example"></a>

SNS 事件來源範例

#### YAML
<a name="sam-property-function-sns--examples--sns-event-source-example--yaml"></a>

```
Events:
  SNSEvent:
    Type: SNS
    Properties:
      Topic: arn:aws:sns:us-east-1:123456789012:my_topic
      SqsSubscription: true
      FilterPolicy:
        store:
          - example_corp
        price_usd:
          - numeric:
              - ">="
              - 100
```

# SqsSubscriptionObject
<a name="sam-property-function-sqssubscriptionobject"></a>

指定 SNS 事件的現有 SQS 佇列選項

## 語法
<a name="sam-property-function-sqssubscriptionobject-syntax"></a>

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

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

```
  [BatchSize](#sam-function-sqssubscriptionobject-batchsize): String
  [Enabled](#sam-function-sqssubscriptionobject-enabled): Boolean
  [QueueArn](#sam-function-sqssubscriptionobject-queuearn): String
  [QueuePolicyLogicalId](#sam-function-sqssubscriptionobject-queuepolicylogicalid): String
  [QueueUrl](#sam-function-sqssubscriptionobject-queueurl): String
```

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

 `BatchSize`   <a name="sam-function-sqssubscriptionobject-batchsize"></a>
單一批次中針對 SQS 佇列擷取的項目數量上限。  
*類型：*字串  
*必要*：否  
*預設值*：10  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `Enabled`   <a name="sam-function-sqssubscriptionobject-enabled"></a>
停用 SQS 事件來源映射以暫停輪詢和調用。  
*類型*：布林值  
*必要*：否  
*預設*：True  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等的。

 `QueueArn`   <a name="sam-function-sqssubscriptionobject-queuearn"></a>
指定現有的 SQS 佇列 arn。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `QueuePolicyLogicalId`   <a name="sam-function-sqssubscriptionobject-queuepolicylogicalid"></a>
為 [AWS::SQS::QueuePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-policy.html) 資源提供自訂 logicalId 名稱。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

 `QueueUrl`   <a name="sam-function-sqssubscriptionobject-queueurl"></a>
指定與 `QueueArn` 屬性相關聯的佇列 URL。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性對 是唯一的 AWS SAM ，並且沒有 CloudFormation 同等屬性。

## 範例
<a name="sam-property-function-sqssubscriptionobject--examples"></a>

### SNS 事件的現有 SQS
<a name="sam-property-function-sqssubscriptionobject--examples--existing-sqs-for-sns-event"></a>

將現有的 SQS 佇列新增至 SNS 主題的範例。

#### YAML
<a name="sam-property-function-sqssubscriptionobject--examples--existing-sqs-for-sns-event--yaml"></a>

```
QueuePolicyLogicalId: CustomQueuePolicyLogicalId
QueueArn:
  Fn::GetAtt: MyCustomQueue.Arn
QueueUrl:
  Ref: MyCustomQueue
BatchSize: 5
```

# SQS
<a name="sam-property-function-sqs"></a>

描述`SQS`事件來源類型的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[搭配使用 AWS Lambda 與 Amazon SQS](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html)。

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

## 語法
<a name="sam-property-function-sqs-syntax"></a>

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

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

```
  [BatchSize](#sam-function-sqs-batchsize): Integer
  [Enabled](#sam-function-sqs-enabled): Boolean
  [FilterCriteria](#sam-function-sqs-filtercriteria): [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)
  [FunctionResponseTypes](#sam-function-sqs-functionresponsetypes): List
  KmsKeyArn: String
  [MaximumBatchingWindowInSeconds](#sam-function-sqs-maximumbatchingwindowinseconds): Integer
  [MetricsConfig](#sam-function-sqs-metricsconfig): [MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)
  [ProvisionedPollerConfig](#sam-function-sqs-provisionedpollerconfig): [ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)
  [Queue](#sam-function-sqs-queue): String
  ScalingConfig: [ScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-scalingconfig.html)
```

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

 `BatchSize`   <a name="sam-function-sqs-batchsize"></a>
要在單一批次中擷取的最大項目數。  
*類型*：整數  
*必要*：否  
*預設值*：10  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[BatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-batchsize)` 屬性。  
*下限*：`1`  
*上限*：`10000`

 `Enabled`   <a name="sam-function-sqs-enabled"></a>
停用事件來源映射以暫停輪詢和叫用。  
*類型*：布林值  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[Enabled](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled)` 屬性。

 `FilterCriteria`   <a name="sam-function-sqs-filtercriteria"></a>
定義判斷 Lambda 是否應處理事件之條件的物件。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[AWS Lambda 事件篩選](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html)。  
*類型*：[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html)` 屬性。

 `FunctionResponseTypes`   <a name="sam-function-sqs-functionresponsetypes"></a>
 目前套用至事件來源映射的回應類型清單。如需詳細資訊，請參閱《 *AWS Lambda 開發人員指南*》中的[報告批次項目失敗](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting)。  
 *有效值*：`ReportBatchItemFailures`  
 *類型：*清單   
 *必要*：否   
 *CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[FunctionResponseTypes](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes)` 屬性。

 `KmsKeyArn`   <a name="sam-function-sqs-kmskeyarn"></a>
金鑰的 Amazon Resource Name (ARN)，用於加密與此事件相關的資訊。  
*類型：*字串  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[KmsKeyArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-kmskeyarn)` 屬性。

 `MaximumBatchingWindowInSeconds`   <a name="sam-function-sqs-maximumbatchingwindowinseconds"></a>
叫用函數之前收集記錄的時間上限，以秒為單位。  
*類型*：整數  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MaximumBatchingWindowInSeconds](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds)` 屬性。

 `MetricsConfig`   <a name="sam-function-sqs-metricsconfig"></a>
選擇加入組態，以取得擷取每個處理階段之事件來源映射的增強指標。如需範例，請參閱 [MetricsConfig 事件](sam-property-function-dynamodb.md#sam-property-function-dynamodb-example-metricsconfigevent)。  
*類型*：[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[MetricsConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-metricsconfig)` 屬性。

 `ProvisionedPollerConfig`   <a name="sam-function-sqs-provisionedpollerconfig"></a>
用於增加用於計算事件來源映射之輪詢器數量的組態。此組態允許最少 2 個輪詢器，最多 2000 個輪詢器。如需範例，請參閱 [ProvisionedPollerConfig 範例](#sam-property-function-sqs-example-provisionedpollerconfig)。  
*類型*：[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ProvisionedPollerConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-provisionedpollerconfig)` 屬性。

 `Queue`   <a name="sam-function-sqs-queue"></a>
佇列的 ARN。  
*類型：*字串  
*必要*：是  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[EventSourceArn](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn)` 屬性。

 `ScalingConfig`   <a name="sam-function-sqs-scalingconfig"></a>
SQS 輪詢器的擴展組態，以控制調用速率並設定並行調用上限。  
*Type (類型)*：`[ScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-scalingconfig.html)`  
*必要*：否  
*CloudFormation 相容性*：此屬性會直接傳遞至 `AWS::Lambda::EventSourceMapping` 資源的 `[ ScalingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-scalingconfig.html)` 屬性。

## 範例
<a name="sam-property-function-sqs--examples"></a>

### MetricsConfig 事件
<a name="sam-property-function-sqs-example-metricsconfigevent"></a>

以下是 資源的範例，該資源使用 `MetricsConfig` 屬性來擷取其事件來源映射的每個處理階段。

```
Resources:
  FilteredEventsFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: s3://sam-demo-bucket/metricsConfig.zip
      Handler: index.handler
      Runtime: nodejs16.x
      Events:
        KinesisStream:
          Type: Kinesis
          Properties:
            Stream: !GetAtt KinesisStream.Arn
            StartingPosition: LATEST
            MetricsConfig:
              Metrics:
              - EventCount
```

### 基本 SQS 事件
<a name="sam-property-function-sqs--examples--sqs-event"></a>

```
Events:
  SQSEvent:
    Type: SQS
    Properties:
      Queue: arn:aws:sqs:us-west-2:012345678901:my-queue
      BatchSize: 10
      Enabled: false
      FilterCriteria:
        Filters:
          - Pattern: '{"key": ["val1", "val2"]}'
```

### 為您的 SQS 佇列設定部分批次報告
<a name="sam-property-function-sqs--examples--sqs-partial-batch"></a>

```
Events:
  SQSEvent:
    Type: SQS
    Properties:
      Enabled: true
      FunctionResponseTypes:
        - ReportBatchItemFailures
      Queue: !GetAtt MySqsQueue.Arn
      BatchSize: 10
```

### 具有已設定擴展之 SQS 事件的 Lambda 函數
<a name="sam-property-function-sqs--examples--sqs-event-scaling"></a>

```
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    ...
    Events:
      MySQSEvent:
        Type: SQS
        Properties:
          ...
          ScalingConfig:
            MaximumConcurrency: 10
```

### ProvisionedPollerConfig 範例
<a name="sam-property-function-sqs-example-provisionedpollerconfig"></a>

```
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    Handler: index.handler
    Runtime: nodejs18.x
    Timeout: 30
    Events:
      SQSEvent:
        Type: SQS
        Properties:
          Queue: !GetAtt MyQueue.Arn
          BatchSize: 10
          Enabled: True
          ProvisionedPollerConfig:
            MaximumPollers: 300
            MinimumPollers: 10
```