How to use references to point for a SQS?


#1

Hello folks!

I’m writing a lambda function that should be triggered when SQS receive a message. It’s working but I’m trying to avoid write sqs names like I did on lambda declaration:

resources:
  Resources:
    WaitingSQS:
      Type: AWS::SQS::Queue   
       Properties:
         QueueName: ${self:provider.environment.WAITING_QUEUE}

functions:
  consumerCallbackQueue:
    handler: src/consumer_callback_queue.handler
    description: Consume SQS callback queue
    events:
      - sqs: arn:aws:sqs:us-east-1:XXXXXXXX:waiting-dev  

My SQS queue is being created by serverless and I would like to write the event using references instead “arn:aws:sqs:us-east-1:XXXXXXXX:waiting-dev”.

Is possible to use references instead what I did?


#2

You can use Fn::GetAtt to return the ARN for a queue.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html