0
votes

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.

1
Are you using the correct event in your Go function's Lambda handler? Or do you not see any event at all in the Lambda Management Console for this function? I do not have experience with the Serverless framework, but believe it isn't much different from the official library and the Serverless Application Model github.com/aws/aws-lambda-go. Is your function deployed to us-east-1?Simon
@Dattatray Not sure if it's an issue, but I don't believe enabled: true is actually required here. Also, Serverless Framework is just a way of interacting with ClodFormation, so probably worth checking the stack out and see exactly what has happened there.K Mo
I don't see any event trigger at all in the Lambda management console. Yes the lambda function is deployed in US-east-1Dattatray
But have you checked what was created in CloudFormation?K Mo

1 Answers

1
votes

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