本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DynamoDB
描述 DynamoDB
事件源类型的对象。有关更多信息,请参阅《Amazon Lambda 开发人员指南》中的将 Amazon Lambda 与 Amazon DynamoDB 结合使用。
如果设置了此事件类型,Amazon SAM 会生成 AWS::Lambda::EventSourceMapping 资源。
语法
要在您的 Amazon Serverless Application Model (Amazon SAM) 模板中声明此实体,请使用以下语法。
YAML
BatchSize:
Integer
BisectBatchOnFunctionError:Boolean
DestinationConfig:DestinationConfig
Enabled:Boolean
FilterCriteria:FilterCriteria
FunctionResponseTypes:List
MaximumBatchingWindowInSeconds:Integer
MaximumRecordAgeInSeconds:Integer
MaximumRetryAttempts:Integer
ParallelizationFactor:Integer
StartingPosition:String
StartingPositionTimestamp:Double
Stream:String
TumblingWindowInSeconds:Integer
属性
-
BatchSize
-
要在单个批次中检索的最大项目数。
类型:整数
必需:否
默认值:100
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的BatchSize
属性。最小值:
1
最大值:
1000
-
BisectBatchOnFunctionError
-
如果函数返回错误,则将批次拆分为两批并重试。
类型:布尔值
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的BisectBatchOnFunctionError
属性。 -
DestinationConfig
-
丢弃的记录的 Amazon Simple Queue Service (Amazon SQS) 队列或 Amazon Simple Notification Service (Amazon SNS)主题目标。
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的DestinationConfig
属性。 -
Enabled
-
禁用事件源映射以暂停轮询和调用。
类型:布尔值
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的Enabled
属性。 -
FilterCriteria
-
定义用于确定 Lambda 是否应处理事件的条件的对象。有关更多信息,请参阅《Amazon Lambda 开发人员指南》中的 Amazon Lambda 事件筛选。
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的FilterCriteria
属性。 -
FunctionResponseTypes
-
当前应用于事件源映射的响应类型的列表。有关详细信息,请参阅《Amazon Lambda 开发人员指南》中的报告批处理项目失败。
有效值:
ReportBatchItemFailures
类型:列表
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的FunctionResponseTypes
属性。 -
MaximumBatchingWindowInSeconds
-
在调用函数之前收集记录的最长时间(以秒为单位)。
类型:整数
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的MaximumBatchingWindowInSeconds
属性。 -
MaximumRecordAgeInSeconds
-
Lambda 发送到函数以进行处理的记录的最长期限。
类型:整数
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的MaximumRecordAgeInSeconds
属性。 -
MaximumRetryAttempts
-
在函数返回错误时重试的最大次数。
类型:整数
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的MaximumRetryAttempts
属性。 -
ParallelizationFactor
-
要从每个分片中同时处理的批次数。
类型:整数
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的ParallelizationFactor
属性。 -
StartingPosition
-
在流中开始读取数据的位置。
-
AT_TIMESTAMP
– 指定开始读取记录的时间。 -
LATEST
- 仅读取新记录。 -
TRIM_HORIZON
- 处理所有可用的记录。
有效值:
AT_TIMESTAMP
|LATEST
|TRIM_HORIZON
类型:字符串
必需:是
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的StartingPosition
属性。 -
-
StartingPositionTimestamp
-
开始读取的时间(以 Unix 时间秒为单位) 在
StartingPosition
被指定为AT_TIMESTAMP
的情况下定义StartingPositionTimestamp
。类型:双精度
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的StartingPositionTimestamp
属性。 -
Stream
-
DynamoDB 流的 Amazon 资源名称(ARN)。
类型:字符串
必需:是
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的EventSourceArn
属性。 -
TumblingWindowInSeconds
-
处理窗口的持续时间(以秒为单位)。有效范围为 1 到 900(15 分钟)。
有关更多信息,请参阅《Amazon Lambda 开发人员指南》的滚动窗口。
类型:整数
必需:否
Amazon CloudFormation 兼容性:此属性直接传递给
AWS::Lambda::EventSourceMapping
资源的TumblingWindowInSeconds
属性。
示例
现有 DynamoDB 表的 DynamoDB 事件源
Amazon 账户中已存在的 DynamoDB 表的 DynamoDB 事件源。
YAML
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 事件
在同一模板文件中声明的 DynamoDB 表的 DynamoDB 事件。
YAML
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