How to create subscription from an SNS to another SNS

1

I have a standard typed SNS. Can I create another SNS subscription from this SNS?

질문됨 2년 전5224회 조회
3개 답변
1
수락된 답변

Hello,

Tim here from the AWS Support Team. As of today’s date, 04/21/2022, SNS supports the following (I'll circle back to your question further down):

  • Amazon Kinesis Data Firehose
  • Amazon SQS
  • AWS Lambda
  • Email
  • Email-JSON
  • HTTP
  • HTTPS
  • Platform application endpoint
  • SMS

For newer endpoints you can see the documentation here: https://docs.aws.amazon.com/sns/latest/dg/sns-create-subscribe-endpoint-to-topic.html

Now let’s circle back to your original question, can you add a SNS subscription to a SNS topic? Right now that isn't supported, however you could design workaround:

  • SNS and fanout to an additional lambda function, and then write a bit of code to push it to another SNS topic.

However, I think there may be a better approach here, where instead of having items published to your first SNS topic, you:

  • Publish it to EventBridge and fanout to multiple SNS resources. Would require a bit of testing to fully see if this is possible, but wanted to share it as a possible way forward. I viewed in my own EventBridge console if I could design an EventBridge rule with multiple SNS resources downstream and it appears possible, however I can't fully test all the quotas that would be specific to your application (you'd need to load test it and do careful examination of your system).

  • Publish to an AWS Lambda function first, then have the Lambda function write to multiple SNS resources. Keep in mind quotas again here, so load test!

  • The best option: wherever you're publishing messages to a SNS topic, just write it to the second SNS topic at the same time. I highly recommend this method. If a service is directly publishing to SNS so it's not some code doing the publishing, checkout EventBridge as a possible method again.

So to summarize a bit:

  • No direct support right now, sorry about that!
  • Workarounds exist, but takes careful evaluation and re-architecting. You'll want to keep in mind quotas, limits, throttling, for the specific workaround you choose.

Hope this helps out!

AWS
지원 엔지니어
Tim_P
답변함 2년 전
profile picture
전문가
검토됨 한 달 전
1

Hey Tim,

The approach Publish to an AWS Lambda function first, then have the Lambda function write to multiple SNS resources. Keep in mind quotas again here, so load test! fits best to me.

Thank you for this through explanation. Alper.

답변함 2년 전
0

Circling back, I found our AWS SDK doc examples that may help with writing that Lambda code: https://github.com/awsdocs/aws-doc-sdk-examples

If you're a fan of Python (Lambda goes great with Python with it's built in code editor for quick tests), I found a specific example: https://github.com/awsdocs/aws-doc-sdk-examples/blob/8ebb71d3a28fdb8ee8bd87b05d8475dfa29a0908/python/example_code/sns/sns_basics.py#L192

AWS
지원 엔지니어
Tim_P
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인