AWS SQS event Trigger for Lambdas Created as Disabled

Hi,

I am testing the new SQS trigger, the creation of the queue and the lambda works well, but the status of the trigger is disabled. This is how my yml looks like:

service:
  name: kopi-orders-api

plugins:
  - serverless-webpack
  - serverless-pseudo-parameters

provider:
  name: aws
  runtime: nodejs8.10
  region: eu-west-1
  stage: ${opt:stage, 'dev'}
  iamRoleStatements:
  - Effect: Allow
    Action:
      - sqs:*
    Resource: arn:aws:sqs:*:*:*
  - Effect: Allow
    Action:
      - sqs:ListQueues
    Resource: "*"

custom:
  ordersQueueName: ${self:provider.stage}-orders-queue

resources:
  Resources:
    ordersQueue:
      Type: "AWS::SQS::Queue"
      Properties:
        QueueName: ${self:custom.ordersQueueName}

functions:
  create-order:
    handler: orders/create.create
    events:
      - sqs:
        arn: arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:${self:custom.ordersQueueName}
        batchSize: 1
        enabled: true

And this is how it looks like in the aws console right after the creation.

If I manually toggle the status to enabled, everything works as expect

Any suggestion on what I am missing?

I tried your exact configuration and I didn’t have any problems. If you can switch it on in the console, then it shouldn’t be a permissions error.

Have you tried deploying without including the enabled: true line in the event config? It is enabled by default.

Hi @jeremydaly

I got it working. the issue was the indentation in the SQS event. it was

functions:
  create-order:
    handler: orders/create.create
    events:
      - sqs:
        arn: arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:${self:custom.ordersQueueName}
        batchSize: 1
        enabled: true

But it should have been

functions:
  create-order:
    handler: orders/create.create
    events:
      - sqs:
          arn: arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:${self:custom.ordersQueueName}
          batchSize: 1
          enabled: true

The template was not failling neither creating the event trigger, but It looks that there was an EventSourceMapping from a previuous execution. so I needed to manually remove via the aws cli aws lambda delete-event-source-mapping --uuid 3a9e218d-61be-4d1c-98a1-23f289a9bea1

Thanks for taking a look.

1 Like

Indentation errors :man_facepalming:t2:

Glad you got it working!