

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

# 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 Ap [i](sam-property-function-api.md) \$1 \$1 \$1 Co [gnito [CloudWatchEvent[CloudWatchLogs](sam-property-function-cloudwatchlogs.md)](sam-property-function-cloudwatchevent.md)](sam-property-function-cognito.md)\$1 documentDB \$1 D [ynamo [DB](sam-property-function-documentdb.md) \$1 \$1 \$1 [Io](sam-property-function-iotrule.md) \$1 [Kinesis [EventBridgeRule](sam-property-function-eventbridgerule.md)\$1 MQ [HttpApi](sam-property-function-httpapi.md)\$1 MS](sam-property-function-kinesis.md) K TRule \$1 S3 \$1 日程](sam-property-function-dynamodb.md)安排 \$1 Schedu [leV2 \$1 \$1](sam-property-function-mq.md)[SNS \$1 SQ](sam-property-function-msk.md) S [SelfManagedKafka](sam-property-function-selfmanagedkafka.md)](sam-property-function-sqs.md)](sam-property-function-sns.md)](sam-property-function-schedulev2.md)](sam-property-function-schedule.md)](sam-property-function-s3.md)  
*是否必需*：是  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

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

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

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

使用 API 事件的示例

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

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

# 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 技能的 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 Skill 事件示例

#### 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 和 body 密钥的对象来控制响应的状态代码和正文。

## 语法
<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\$1路径\$1方法的身份验证配置。  
对于未指定 `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`、`POST`、`PUT` 和 `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\$1路径\$1方法 的请求模型。这应该引用 [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` 开头，且必须限制为 `method.request.header`、`method.request.querystring`、或`method.request.path`。  
列表既可以包含参数名称字符串，也可以包含[RequestParameter](sam-property-function-requestparameter.md)对象。对于字符串，`Required` 和 `Caching` 属性将默认为 `false`。  
*类型*：[字符串 \$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 定义。必须使用 `DefinitionBody` 属性内联指定 OpenAPI 定义。
*类型*：整数  
*必需*：否  
*默认值*：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>
指定用于 `AWS_IAM` 授权的 `InvokeRole`。  
*类型*：字符串  
*必需*：否  
*默认值*：`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` 资源的 `DefinitionBody` 属性来描述您的 API 时，才需要此属性。  
当你指定`OverrideApiAuth`为时`true`， AWS SAM 将使用为、或`ResourcePolicy`提供的任何值覆盖你的全局授权`ApiKeyRequired`者`Authorizer`。因此，使用 `OverrideApiAuth` 时还必须指定其中至少一个属性。有关示例，请参阅[指定 for 时 DefinitionBody 覆盖全局授权 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>

### 函数身份验证
<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
```

### 指定 for 时 DefinitionBody 覆盖全局授权 AWS::Serverless::Api 方
<a name="sam-property-function-apifunctionauth--examples--override2"></a>

当使用 `DefinitionBody` 属性描述 `AWS::Serverless::Api` 资源时，之前的覆盖方法不起作用。以下是对 `AWS::Serverless::Api` 资源使用 `DefinitionBody` 属性的示例：

```
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\$1 方法配置请求模型。

## 语法
<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) Models 属性中定义的模型的名称。  
*类型*：字符串  
*是否必需*：是  
*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\$1路径\$1方法配置请求参数。

需要为请求参数指定 `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>
在 API Gateway OpenApi 定义中添加`cacheKeyParameters`章节  
*类型*：布尔值  
*必需*：条件  
*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)。  
*类型*：[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>

Cloudwatchlog 订阅筛选示例

#### 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 与亚马逊 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 资源名称（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 资源名称（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>
来自 Secrets Manager 的客户托管密钥的 AWS Key Management Service (AWS KMS) AWS 密钥 ID。当您以不包含 `kms:Decrypt` 权限的 Lambda 执行角色使用来自 Secrets Manager 的客户托管密钥时，此为必需。  
此属性的值为 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 时间秒为单位） 在 `StartingPosition` 被指定为 `AT_TIMESTAMP` 的情况下定义 `StartingPositionTimestamp`。  
*类型*：双精度  
*必需*：否  
*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 LambdaAWS Lambda 与亚马逊 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 Notiﬁcation 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 资源名称（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 时间秒为单位） 在 `StartingPosition` 被指定为 `AT_TIMESTAMP` 的情况下定义 `StartingPositionTimestamp`。  
*类型*：双精度  
*必需*：否  
*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 资源名称（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>

账户中已存在的 DynamoDB 表的 DynamoDB 事件源。 AWS 

#### 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 规则的目标。有关更多信息，请参阅[什么是亚马逊 EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html) 在《*亚马逊 EventBridge 用户指南》*中。

AWS SAM 设置此事件类型时会生成[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html)资源。 AWS SAM 还会创建`AWS::Lambda::Permission`资源，该资源是调用 Lambda 所`EventBridgeRule`必需的。

## 语法
<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>
配置亚马逊简单队列服务 (Amazon SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的 Lambda 函数发送事件时，或者没有足够的权限调用 Lambda 函数 EventBridge 时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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>
使您可以根据特定事件数据向目标提供自定义输入的设置。您可以从事件中提取一个或多个键值对，然后使用该数据将自定义输入发送到目标。有关更多信息，请参阅[亚马逊* EventBridge 用户指南中的亚马逊 EventBridge *输入转换](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html)。  
*类型*：[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-inputtransformer)  
*必需*：否  
*CloudFormation 兼容性*：此属性直接传递给`AWS::Events::Rule``Target`数据类型的`[InputTransformer](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-inputtransformer.html)`属性。

 `Pattern`   <a name="sam-function-eventbridgerule-pattern"></a>
描述哪些事件路由到指定目标。有关更多信息，请参阅[亚马逊* EventBridge 用户指南中的亚马逊 EventBridgeEventBridge *事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html)[和事件模式](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html)。  
*类型*：[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)  
*是否必需*：是  
*CloudFormation 兼容性*：此属性直接传递给`AWS::Events::Rule`资源的`[EventPattern](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-eventpattern)`属性。

 `RetryPolicy`   <a name="sam-function-eventbridgerule-retrypolicy"></a>
包含有关重试策略设置的信息的 `RetryPolicy` 对象。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*类型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)  
*必需*：否  
*CloudFormation 兼容性*：此属性直接传递给`AWS::Events::Rule``Target`数据类型的`[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)`属性。

 `RuleName`   <a name="sam-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。  
*类型*：[目标](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 SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，在向不存在的 Lambda 函数发送事件或调用 Lambda 函数的权限不足时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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 资源名称（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>
指定了 AWS SAM 创建的死信队列的自定义名称。`Type`  
如果未设置 `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\$1路径\$1方法的身份验证配置。  
在未指定 `DefaultAuthorizer` 的情况下，对于覆盖 API 的 `DefaultAuthorizer` 或在各个路径中设置身份验证配置很有用。  
*类型*：[HttpApiFunctionAuth](sam-property-function-httpapifunctionauth.md)  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `Method`   <a name="sam-function-httpapi-method"></a>
调用此函数的 HTTP 方法。  
如果未指定 `Path` 和 `Method`，SAM 会创建默认 API 路径，用于将未映射到其他端点的任何请求路由到此 Lambda 函数。每个 API 只能存在其中一个默认路径。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `Path`   <a name="sam-function-httpapi-path"></a>
调用此函数的 URI 路径。必须以 `/` 开头。  
如果未指定 `Path` 和 `Method`，SAM 会创建默认 API 路径，用于将未映射到其他端点的任何请求路由到此 Lambda 函数。每个 API 只能存在其中一个默认路径。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

 `PayloadFormatVersion`   <a name="sam-function-httpapi-payloadformatversion"></a>
指定发送到集成的有效负载的格式。  
注意： PayloadFormatVersion 需要 SAM 修改您的 OpenAPI 定义，因此它仅适用于属性中 OpenApi 定义的内联定义。`DefinitionBody`  
*类型*：字符串  
*必需*：否  
*默认值*：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)*中的。  
注意：如果 RouteSettings 在 HttpApi 资源和事件源中同时指定，则将其 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 定义，因此它仅适用于属性中 OpenApi 定义的内联定义。`DefinitionBody`  
*类型*：整数  
*必需*：否  
*默认值*：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` 部分指定 `AWS_IAM`，并为 `EnableIamAuthorizer` 指定 `true`。  
如果您已在 API 中指定了全局授权方并想公开特定函数，请通过将 `Authorizer` 设置为 `NONE` 来覆盖。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性是独有的 AWS SAM ，没有 CloudFormation 等效属性。

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

### 函数身份验证
<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` 事件源类型的对象。

创建用于声明 AWS IoT 规则的[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)资源。有关更多信息，请参阅 [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 Notiﬁcation 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 资源名称（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 时间秒为单位） 在 `StartingPosition` 被指定为 `AT_TIMESTAMP` 的情况下定义 `StartingPositionTimestamp`。  
*类型*：双精度  
*必需*：否  
*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 资源名称（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 开发人员指南》**中[结合 Amazon MQ 使用 Lambda](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）中建立 Amazon MQ 队列并连接到公共网络中的 Lambda 函数，函数的执行角色必须包含以下权限：  
`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 资源名称（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 policy 使用自动生成的名称。此名称包含 Amazon MQ 事件源逻辑 ID。  
使用多个 Amazon MQ 事件源时，请指定 `true`，以避免重复的 IAM policy 名称。
*类型*：布尔值  
*必需*：否  
*默认值*：`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 资源名称（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 将使用此 RabbitMQ 的主机作为事件源。只允许使用一个类型为 `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 资源名称（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 时间秒为单位） 在 `StartingPosition` 被指定为 `AT_TIMESTAMP` 的情况下定义 `StartingPositionTimestamp`。  
*类型*：双精度  
*必需*：否  
*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 资源名称（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>

以下示例显示了 AWS 账户中已存在的 Amazon MSK 集群的 `MSK` 事件源类型。

#### 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 事件
<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 规则的目标。有关更多信息，请参阅[什么是亚马逊 EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html) 在《*亚马逊 EventBridge 用户指南》*中。

AWS Serverless Application Model (AWS SAM) 在设置此事件类型时生成[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html)资源。

**注意**  
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>
配置亚马逊简单队列服务 (Amazon SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的 Lambda 函数发送事件时，或者没有足够的权限调用 Lambda 函数 EventBridge 时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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` 对象。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html)。  
*类型*：[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)  
*必需*：否  
*CloudFormation 兼容性*：此属性直接传递给`AWS::Events::Rule``Target`数据类型的`[RetryPolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html#cfn-events-rule-target-retrypolicy)`属性。

 `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 SQS) Simple Queue Service 队列的对象，目标调用失败后 EventBridge 在该队列中发送事件。例如，在向不存在的 Lambda 函数发送事件或调用 Lambda 函数的权限不足时，调用可能会失败。有关更多信息，请参阅 A *ma EventBridge * zon 用户指南中的[事件重试策略和使用死信队列](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 资源名称（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>
指定了 AWS SAM 创建的死信队列的自定义名称。`Type`  
如果未设置 `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 S EventBridge cheduler 事件的目标。有关更多信息，请参阅[什么是 Amazon EventBridge 日程安排](https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html)？ 在《*EventBridge 日程安排器用户指南》*中。

AWS Serverless Application Model (AWS SAM) 在设置此事件类型时生成[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html)资源。

## 语法
<a name="sam-property-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 SQS) Simple Queue Service 队列，目标调用失败后 EventBridge 在该队列中发送事件。例如，当向不存在的 Lambda 函数发送事件时，或者没有足够的权限调用 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 与自行管理的 Apache Kafka 配合使用](https://docs.aws.amazon.com/lambda/latest/dg/with-kafka.html)。AWS Lambda *

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 资源名称（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 时间秒为单位） 在 `StartingPosition` 被指定为 `AT_TIMESTAMP` 的情况下定义 `StartingPositionTimestamp`。  
*类型*：双精度  
*必需*：否  
*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
```

### 自托管 Kafka 事件源与 Confluent 架构注册表
<a name="sam-property-function-selfmanagedkafka-example-schemaregistry-confluent"></a>

以下是一个配置了 Confluent 架构注册表的 `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。有关更多信息，请参阅[GetSubscriptionAttributes](https://docs.aws.amazon.com/sns/latest/api/API_GetSubscriptionAttributes.html)《亚马逊简单通知服务 API 参考》。  
*类型*：[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>
为资源提供一个自定义 LogicalID 名称。[AWS::SQS::QueuePolicy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-policy.html)  
*类型*：字符串  
*必需*：否  
*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 资源名称（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 轮询器的配置，以控制调用速率并设置最大并发调用次数。  
*类型*：`[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
```