hkj*_*dj1 4 amazon-sqs amazon-web-services aws-lambda aws-sam
我有一个 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
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
错误:无法为堆栈创建变更集:gitlabpoc,例如:Water ChangeSetCreateComplete 失败:Water 遇到终端故障状态状态:FAILED。原因:模板格式错误:无法识别的资源类型:[SQS]
我正在关注这个文件:
还有这个文件:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
但我不能告诉我现有队列的arn
我怎样才能做到这一点?
我想通了,因为Queue: !GetAtt FooBarSQS.Arn我的OrderDrop's 中的属性Event需要队列 arn,我只是给了它我现有队列的 arn。
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: arn:aws:sqs:us-east-1:1234567890:foobar_queue.fifo
BatchSize: 1
Run Code Online (Sandbox Code Playgroud)
这成功了!
| 归档时间: |
|
| 查看次数: |
1304 次 |
| 最近记录: |