DynamoDB 应用程序的 AWS SAM 模板 - AWS Lambda

DynamoDB 应用程序的 AWS SAM 模板

您可以使用 AWS SAM 构建此应用程序。要了解有关创建 AWS SAM 模板的更多信息,请参阅 AWS Serverless Application Model 开发人员指南中的 AWS SAM 模板基础知识

下面是教程应用程序的示例 AWS SAM 模板。将以下文本复制到 .yaml 文件中,并将其保存到您之前创建的 ZIP 程序包旁。请注意,HandlerRuntime 参数值应与上一节中创建函数时所用的参数值匹配。

例 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

有关如何使用程序包和部署命令打包和部署无服务器应用程序的信息,请参阅 AWS Serverless Application Model 开发人员指南中的部署无服务器应用程序