Reputation: 886
I have a lambda function that is supposed to be triggered when a message arrives in my queue. I am developing & deploying this function via SAM cli. But, the SQS queue already exists and I can not create it along with the lambda function due to a restriction in my use case. So, I have to use this existing queue.
following is my 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
I am getting the following error:
Error: Failed to create changeset for the stack: gitlabpoc, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Template format error: Unrecognized resource types: [SQS]
I was following this document:
There is also this document:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html
But I can't anything where I can tell the arn of my existing queue
How can I achieve this?
Upvotes: 4
Views: 3413
Reputation: 886
I figured it out, since the Queue: !GetAtt FooBarSQS.Arn
property in my OrderDrop
's Event
requires the Queue arn, I just gave it the arn of my existing queue.
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
This did the trick!
Upvotes: 9