本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DynamoDB 应用程序的 Amazon SAM 模板
您可以使用 Amazon SAM 构建此应用程序。要了解有关创建 Amazon SAM 模板的更多信息,请参阅 Amazon Serverless Application Model 开发人员指南中的 Amazon SAM 模板基础知识。
下面是教程应用程序的示例 Amazon SAM 模板。将以下文本复制到 .yaml 文件中,并将其保存到您之前创建的 ZIP 程序包旁。请注意,Handler
和 Runtime
参数值应与上一节中创建函数时所用的参数值匹配。
例 template.yaml
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: ProcessDynamoDBStream: Type: AWS::Serverless::Function Properties: Handler:
handler
Runtime:runtime
Policies: AWSLambdaDynamoDBExecutionRole Events: Stream: Type: DynamoDB Properties: Stream: !GetAtt DynamoDBTable.StreamArn BatchSize: 100 StartingPosition: TRIM_HORIZON DynamoDBTable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - AttributeName: id KeyType: HASH ProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5 StreamSpecification: StreamViewType: NEW_IMAGE
有关如何使用程序包和部署命令打包和部署无服务器应用程序的信息,请参阅 Amazon Serverless Application Model 开发人员指南中的部署无服务器应用程序。