Serverless does not create SQS events

笑着哭i 提交于 2021-01-28 01:56:01

问题


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


回答1:


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




回答2:


Add 2 spaces on the sqs. Added a picture for good measure!




回答3:


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.



来源:https://stackoverflow.com/questions/51974560/serverless-does-not-create-sqs-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!