Amazon SAMAmazon SQS 应用程序的 模板
您可以使用 Amazon SAM 构建此应用程序。要了解有关创建 Amazon SAM 模板的更多信息,请参阅 Amazon Serverless Application Model 开发人员指南中的 Amazon SAM 模板基础知识。
下面是教程中 Lambda 应用程序的示例 Amazon SAM 模板。将以下文本复制到 .yaml 文件中,并将其保存到您之前创建的 ZIP 程序包旁。请注意,Handler
和 Runtime
参数值应与上一节中创建函数时所用的参数值匹配。
例 template.yaml
AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Example of processing messages on an SQS queue with Lambda Resources: MySQSQueueFunction: Type: AWS::Serverless::Function Properties: Handler:
index.handler
Runtime:nodejs12.x
Events: MySQSEvent: Type: SQS Properties: Queue: !GetAtt MySqsQueue.Arn BatchSize: 10 MySqsQueue: Type: AWS::SQS::Queue
有关如何使用程序包和部署命令打包和部署无服务器应用程序的信息,请参阅 Amazon Serverless Application Model 开发人员指南中的部署无服务器应用程序。