Skip to content

Conversation

@cmcnicholas
Copy link
Contributor

@cmcnicholas cmcnicholas commented Jul 2, 2023

This PR adds support for subscriptions in Queue constructs, see: #266

There are quite a few use cases for this but a common pattern is "fanout" https://aws.amazon.com/getting-started/hands-on/send-fanout-event-notifications/ used to distribute messages to multiple queues that have different processing concerns/domains.

Example using this functionality.

service: lift-test
configValidationMode: error

plugins:
  - serverless-lift

provider:
  name: aws
  region: eu-west-1
  versionFunctions: false

resources:
  Resources:
    MyTopic:
      Type: 'AWS::SNS::Topic'
      Properties:
        TopicName: SuperTopic

constructs:
  ## adds a simple queue and unfiltered subscription against an ARN
  my-queue:
    type: queue
    worker:
      handler: worker.handler
    subscriptions:
      - topicArn: arn:aws:sns:eu-west-1:XXXXXXXXX:AnotherTopic

  ## more complex: adds multiple filtered subscriptions against an ARN and resource defined in this config
  my-queue:
    type: queue
    worker:
      handler: worker.handler
    subscriptions:
      - topicArn: arn:aws:sns:eu-west-1:XXXXXXXXX:DifferentTopic
      - topicArn: arn:aws:sns:eu-west-1:XXXXXXXXX:AlternateTopic
        filters:
          - attribute: yyy
            allows:
              - hello
              - world
      - topicRef: MyTopic
        filters:
          - attribute: xxx
            denied:
              - other
              - world

@cmcnicholas cmcnicholas changed the title feat: adds subscription support Queue Subscriptions Jul 2, 2023
@cmcnicholas cmcnicholas marked this pull request as ready for review July 25, 2023 21:07
@cmcnicholas
Copy link
Contributor Author

This PR is now ready :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant