serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

SQS Queues #136

Open bryanrcampbell opened 6 years ago

bryanrcampbell commented 6 years ago

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!

franciscomemoli commented 4 years ago

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

bryanrcampbell commented 4 years ago

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.