Dattatray
Dattatray

Reputation: 1875

AWS Serverless : SQS Lambda trigger not getting created

I am using Serverless framework and trying to create SQS triggers for lambda function.

The SQS Queue is already created using another serverless template.

When I execute the serverless deploy command, there are no errors, but the SQS trigger is also not created.

Here is my serverless.yml file

service: cloudformation-demo

plugins:
  - serverless-pseudo-parameters

custom:
  CONNECT_DEVICE_SQS_ROLE_NAME: SqSConnectRole
  CONNECT_DEVICE_SQS_QUEUE_NAME: connectDeviceSQSDemo1


provider:
  name: aws
  runtime: go1.x
  stage: dev
  region: us-east-1


package:
 individually: true
 exclude:
   - ./**

functions:
   lambdaenvinfo:
    handler: bin/handlers/lambdaenvinfo
    timeout: 900
    package:
     exclude:
        - "**/**"
     include:
       - ./bin/handlers/lambdaenvinfo
     events:
      - sqs:
         arn: arn:aws:sqs:us-east-1:672851574246:connectDeviceSQSDemo
         batchSize: 1
         enabled: true

I also referred to this thread, and tried to add required spaces.

Serverless does not create SQS events

Any solutions to this problem? It's surprising to see serverless doesn't display any errors.

Upvotes: 0

Views: 1490

Answers (1)

Dattatray
Dattatray

Reputation: 1875

I was able to solve this issue, the lambda SQS triggers are getting created now.

Main Problems -

  1. Indentation of the serverless.yml file needs to be correct ( in this case, serverless doesn't give any errors)

( Observe the spaces before sqs, events, include, exclude, in the below serverless yml file )

  1. The format to specify the event trigger for Lambda in case of SQs is bit different.

sqs: arn:aws:sqs:us-east-1:672851574246:connectDeviceSQSDemo

I have modified the serverless.yml file ( it's working now)

service: cloudformation-demo

plugins:
  - serverless-pseudo-parameters

custom:
  CONNECT_DEVICE_SQS_ROLE_NAME: SqSConnectRole
  CONNECT_DEVICE_SQS_QUEUE_NAME: connectDeviceSQSDemo1


provider:
  name: aws
  runtime: go1.x
  stage: dev
  region: us-east-1


package:
 individually: true
 exclude:
   - ./**

functions:
  lambdaenvinfo:
    handler: bin/handlers/lambdaenvinfo
    timeout: 30
    package:
      exclude:
        - "**/**"
      include:
       - ./bin/handlers/lambdaenvinfo
    events:
       - sqs: arn:aws:sqs:us-east-1:672851574246:connectDeviceSQSDemo

Upvotes: 2

Related Questions