我有一个lambda函数,应该在消息到达我的队列时触发。我正在通过SAM cli开发和部署此功能。但是,SQS队列已经存在,由于用例的限制,我无法与lambda函数一起创建它。因此,我必须使用此现有队列。
以下是我的template.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Serverless functions for foobar
Globals:
Function:
Timeout: 60 # 60 seconds timeout for each lambda function
Resources:
# Lambda function #1; foobar SQS trigger
OrderDrop:
Type: AWS::Serverless::Function
Properties:
CodeUri: sqs_trigger/foobar
Handler: app.lambda_handler
Runtime: python3.8
Description: foobar SQS trigger
Events:
FooBarSQS:
Type: SQS
Properties:
Queue: !GetAtt FooBarSQS.Arn
BatchSize: 1
# Foobar SQS
FooBarSQS:
Type: SQS
Properties:
Queue: arn:aws:sqs:us-east-1:1234567890:foobar_queue.fifo
Enabled: true
我遇到以下错误:
错误:无法为堆栈创建更改集:gitlabpoc,例如:服务员ChangeSetCreateComplete失败:服务员遇到终端失败状态状态:失败。原因:模板格式错误:无法识别的资源类型:[SQS]
我正在关注此文档:
也有此文档:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
但是我无法告诉我现有队列的信息
我该如何实现?
答案 0 :(得分:3)
我发现了这一点,因为Queue: !GetAtt FooBarSQS.Arn
的{{1}}中的OrderDrop
属性需要Queue arn,所以我只给了我现有队列的arn。
Event
这成功了!