agiledigital / serverless-sns-sqs-lambda

serverless plugin to make serverless-sns-sqs-lambda events
Apache License 2.0
81 stars 18 forks source link

Queue names always include dev whatever the stage #432

Closed owenbendavies closed 2 years ago

owenbendavies commented 2 years ago

When running as a different stage, e.g.

serverless deploy --stage staging

with the following config

service: platform-backgroundjobs

plugins:
  - '@agiledigital/serverless-sns-sqs-lambda'

resources:
  Resources:
    Topic:
      Type: AWS::SNS::Topic
      Properties:
        ContentBasedDeduplication: true
        FifoTopic: true
        TopicName: !Join ['', [!Ref AWS::StackName, '.fifo']]

functions:
  example:
    handler: src/handlers/example.handler
    events:
      - snsSqs:
          batchSize: 1
          fifo: true
          maxRetryCount: 1
          name: message
          rawMessageDelivery: true
          topicArn: !Ref Topic

The lambda functions are named correctly, e.g. platform-backgroundjobs-staging-example however the queues are named with dev, e.g. platform-backgroundjobs-dev-ExamplemessageQueue.fifo and platform-backgroundjobs-dev-ExamplemessageDeadLetterQueue.fifo

Thank you for your plugin as it cleans up the code a lot rather than writing the cloudformation resources manually.

NoxHarmonium commented 2 years ago

Hi there, thanks for the report!

That might be related to the recent change to add fifo queues. I'll try and have a look at it this weekend.

robinMcA commented 2 years ago

@NoxHarmonium I think that that it could also be related to how severless creates the stage variable. https://github.com/agiledigital/serverless-sns-sqs-lambda/blob/master/lib/serverless-sns-sqs-lambda.ts#L293 the default naming pull in ${stage} from the serverless config. https://github.com/agiledigital/serverless-sns-sqs-lambda/blob/master/lib/serverless-sns-sqs-lambda.ts#L202 Need to see what --stage staging sets.

robinMcA commented 2 years ago

@NoxHarmonium is only this line will look at adding test for it later.

NoxHarmonium commented 2 years ago

@owenbendavies a workaround for now while we get the fix through would be adding your stage name to the provider section of your serverless config,

For example:

provider:
  stage: ${opt:stage, 'dev'}

You may need to tweak that a bit if you use something like environment variables for your stage.

NoxHarmonium commented 2 years ago

Since this will technically be a breaking change, maybe this is our opportunity to bump up the version to v1

owenbendavies commented 2 years ago

@NoxHarmonium adding stage to provider worked as a temporary solution, thank you.

NoxHarmonium commented 2 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: