Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SNS subscriptions to queues #266

Open
jesusch opened this issue Sep 15, 2022 · 14 comments
Open

Add SNS subscriptions to queues #266

jesusch opened this issue Sep 15, 2022 · 14 comments

Comments

@jesusch
Copy link

jesusch commented Sep 15, 2022

I assum this could be a common usecase

constructs:
  my-queue:
    type: queue
    subscriptions:
    - arn:aws:sns:us-east-1:1234567890:my-topic
    - arn:aws:sns:eu-west-1:1234567890:my-othertopic
@mnapoli
Copy link
Member

mnapoli commented Sep 16, 2022

What would be the use case?

@jesusch
Copy link
Author

jesusch commented Oct 11, 2022 via email

@Agrumas
Copy link

Agrumas commented Oct 11, 2022

I also have a similar need in event-driven architecture.
For example, a service sends events to SNS topic and other services have their own SQS queue to process messages from other services. A subscription is needed to filter and get events from other services.

@otaviodantas
Copy link

I have the same need as @Agrumas :/

@ryanwalters
Copy link

What would be the use case?

A common pattern, usually called "fanout", is to subscribe SQS queues to SNS topics. AWS documentation has a basic example of the pattern here: https://aws.amazon.com/getting-started/hands-on/send-fanout-event-notifications/

Here's an example of what the CloudFormation configuration looks like (there's probably a CDK example out there too): https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#aws-resource-sns-subscription--examples--Create_a_subscription_with_optional_attributes--yaml

Note the protocol set to sqs.

@cmcnicholas
Copy link
Contributor

What would be the use case?

A common pattern, usually called "fanout", is to subscribe SQS queues to SNS topics. AWS documentation has a basic example of the pattern here: https://aws.amazon.com/getting-started/hands-on/send-fanout-event-notifications/

Here's an example of what the CloudFormation configuration looks like (there's probably a CDK example out there too): https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html#aws-resource-sns-subscription--examples--Create_a_subscription_with_optional_attributes--yaml

Note the protocol set to sqs.

Exactly this, I'm experiencing this on a project at the moment and have seen this used before in a few places, it's quite common for allowing resilient simplified async processing of independent pipelines e.g.

image

@cmcnicholas
Copy link
Contributor

I've had a stab at implementing this, see #344

I would appreciate any help simplifying or helping to resolve the issue about having to use ARN strings instead of Refs.

@cmcnicholas
Copy link
Contributor

sorry to chase up on this, after doing a little bit of digging I still can't find the "plugin way" to resolve refs in the linked PR e.g.

constructs:
  ## adds a simple queue and unfiltered subscription
  my-queue:
    type: queue
    worker:
      handler: worker.handler
    subscriptions:
      - topic: !Ref MyTopic # this doesn't work

does anyone have any reference material for working with refs that need to be resolved dynamically with lift?

@cmcnicholas
Copy link
Contributor

I've opened a discussion for this too #345

@cmcnicholas
Copy link
Contributor

Managed to resolve it, PR now ready #344

@johnrobertcobbold
Copy link

@cmcnicholas it seems that your PR never got merged? It's such a nice feature

@cmcnicholas
Copy link
Contributor

@cmcnicholas it seems that your PR never got merged? It's such a nice feature

Yer is a shame, I feel like this is a really common pattern.

I've forked and been using it in a live project for a few months now so feel free to do the same until it maybe ends up in lift natively.

@johnrobertcobbold
Copy link

@mnapoli Would you consider merging/looking into @cmcnicholas's PR? The fanout pattern described above is very useful and without this PR, we are currently having to manually create the SNS subscription for the SQS queue created with lift.

@madCodes
Copy link

madCodes commented Mar 7, 2024

@mnapoli , this pattern is almost universal. Not sure, why this is not getting the love it deserves :)

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

No branches or pull requests

8 participants