2
votes

I am trying to make serverless create a trigger to fire whenever an object queues. But it does not create and also does not fire any errors.

My serverless.yml: I did according to the documentation (https://serverless.com/framework/docs/providers/aws/events/sqs/)

service: lambda-messages

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: us-east-1
  memorySize: 256
  iamRoleStatements:
   - Effect: "Allow"
     Action:
     - sqs:SendMessage
     - sqs:ReceiveMessage
     - sqs:DeleteMessage
     - sqs:GetQueueAttributes
     Resource: arn:aws:sqs:us-east-1:074601456889:messages

functions:
  addMessages:
    timeout: 10
    handler: handler.addMessages
    events:
     - http:
         path: v1/chat/addMessages
         method: post

  receiveMessage:
    timeout: 10
    handler: handler.receiveMessage
    reservedConcurrency: 10
    events:
     - sqs:
       arn: arn:aws:sqs:us-east-1:074601456889:messages
       batchSize: 2

But it does not create

Image console lambda

3
Does the SQS queue already exist in the account? or are you trying to create it in this project? - Matt D

3 Answers

1
votes

The problem is with the indentation in your YAML file, just add two spaces in front of "arn" and "batchSize"

1
votes

enter image description here Add 2 spaces on the sqs. Added a picture for good measure!

-1
votes

You have to create queue by yourself, as mentioned in documentation.
Because serverless won't create SQS for you, it can only put listener on already existing queue.
You can find how to do it here.
Serverless don't create SQS for you because there is two types of queues available to choose according to your needs. It's up to you to choose the queue type, then create it and only after this serverless will find your queue and attach worker.