serverless-aws-alias icon indicating copy to clipboard operation
serverless-aws-alias copied to clipboard

SQS Queues

Open bryanrcampbell opened this issue 5 years ago • 2 comments

We are using serverless 1.28 to setup lambda triggers. https://serverless.com/framework/docs/providers/aws/events/sqs/

Without the serverless-aws-alias plugin, this functionality works correctly. With it, we run into some really odd problems where all functions are subscribed to one of the SQS queues.

I tracked the issue down to this code: https://github.com/HyperBrain/serverless-aws-alias/blob/master/lib/stackops/events.js#L34-L40 - it ends up with an undefined resourceRefName.

A subscription the code is looking at looks something like the following (from cloudformation-template-update-stack.json):

"ProcessCardTransactionEventSourceMappingSQSCardtransactions": {
      "Type": "AWS::Lambda::EventSourceMapping",
      "DependsOn": "IamRoleLambdaExecution",
      "Properties": {
        "BatchSize": 1,
        "EventSourceArn": "arn:aws:sqs:us-east-1:123456789:card-transactions",
        "FunctionName": {
          "Fn::GetAtt": [
            "ProcessCardTransactionLambdaFunction",
            "Arn"
          ]
        },
        "Enabled": "True"
      }
    },

Here is a snippet from my serverless.yml

functions:
  processCardTransaction:
    handler: dist/handlers/cardTransactions
    timeout: 30
    reservedConcurrency: 1
    events:
      - sqs:
          arn: "arn:aws:sqs:us-east-1:123456789:card-transactions"
          batchSize: 1
          enabled: true
  processBankTransaction:
    handler: dist/handlers/bankTransactions
    timeout: 30
    reservedConcurrency: 1
    events:
      - sqs:
          arn: "arn:aws:sqs:us-east-1:123456789:bank-transactions"
          batchSize: 1
          enabled: true

Any help here would be appreciated.

Thanks!

bryanrcampbell avatar Sep 13 '18 14:09 bryanrcampbell

have you found some solution to this problem? at least some temporary workaround?

franciscomemoli avatar Jun 18 '20 19:06 franciscomemoli

I didn’t. I actually ended up punting on setting up event source mappings with serverless. Instead we use serverless to manage lambda infrastructure and terraform to manage the rest. I was skeptical having it split but it works really well.

Using something like terraform is likely inevitable given the number of things serverless doesn’t support.

bryanrcampbell avatar Jun 21 '20 17:06 bryanrcampbell