AWS Async Messaging
I’ve already had an article about Serverless Challenges kind of performance and etc…
Here i want to talk about an inconvenient behavior of SNS service.
How it works?
Add alt text
Simply the SNS recieves the messages and distributes them to the subscribers which could be the SQS, Http endpoint, LambdaFunction, SES, SMS or mobile push endpoint. it will send messages as soon as they arrive.
Your SNS:
The SNS can be created using this simple template
MySNSTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
-
Endpoint:
Fn::GetAtt:
- "SQSProduct"
- "Arn"
Protocol: "sqs"
- Endpoint:
Fn::GetAtt:
- "SQSProductPropagation"
- "Arn" Protocol: "sqs" TopicName: "SampleTopic"
The topic has two subscribers and it will distribute the messages to them. But if you need another subscriber you will change the template as bellow
MySNSTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
-
Endpoint:
Fn::GetAtt:
- "SQSProduct"
- "Arn"
Protocol: "sqs"
- Endpoint:
Fn::GetAtt:
- "SQSProductPropagation"
- "Arn"
Protocol: "sqs"
- Endpoint:
Fn::GetAtt:
- "SQSProductEnhancement"
- "Arn"
Protocol: "sqs"
TopicName: "SampleTopicEnhancedProduct"
Every thing goes well till you do this update on production, per AWS documentation the Name modification will cause the topic replacement so you will lost all your messages already in production