Amazon SNS Filter control and access - amazon-sns

Looking to setup a aws SNS topic - I intend to subscribe a third party to this topic and I’m hoping that I can use its message filtering to ensure said third party only gets the messages they need.
Is that possible? Since I control the SNS topic I’m hoping I can also control who gets to see what but the docs are not super clear.

From Amazon SNS Message Filtering - Amazon Simple Notification Service:
By default, an Amazon SNS topic subscriber receives every message published to the topic. To receive a subset of the messages, a subscriber must assign a filter policy to the topic subscription.
A filter policy is a simple JSON object containing attributes that define which messages the subscriber receives. When you publish a message to a topic, Amazon SNS compares the message attributes to the attributes in the filter policy for each of the topic's subscriptions. If any of the attributes match, Amazon SNS sends the message to the subscriber. Otherwise, Amazon SNS skips the subscriber without sending the message. If a subscription doesn't have a filter policy, the subscription receives every message published to its topic.

Related

Flutter FCM Topic named like a document

I am new to firebase cloud messaging and i search the best way to send notifications to clients.
I want people to be able to subscribe to new entry in subcollection like this :
books/{bookID}/comments/{commentId}/reply/{replyId}}
Is that bad if i use that kind of syntax?
so i can push notification on that topic when new reply are created
void fcmSubscribe(String bookId,String commentId) {
firebaseMessaging.subscribeToTopic('book-${bookiD}_comment-${commentId}');
}
or i need to use Individual Device Notifications and create entries like this
books/{bookID}/comments/{commentId}/notifications/{tokenId}}
i want to avoid firestore Read and Write.
You can use whatever valid topic names that you want. Use whatever you like - it's your choice. There is nothing particularly "bad" about your choice of name, as long as it works for you. Things can only go badly for you if you exceed one of the documented limits for topic messaging:
Topic messaging supports unlimited subscriptions for each topic. However,
FCM enforces limits in these areas:
One app instance can be subscribed to no more than 2000 topics.
If you are using batch import to subscribe app instances, each request is limited to 1000 app instances.
The frequency of new subscriptions is rate-limited per project. If you send too many subscription requests in a short period of time, FCM
servers will respond with a 429 RESOURCE_EXHAUSTED ("quota exceeded")
response. Retry with exponential backoff.
If you're thinking that FCM is tied in any way to Firestore, that's not the case. You are not obliged to make anything match between your Firesore documents and your FCM topics.

How do I customize message in SNS topic notification triggered on cloudwatch rules?

I have a cloudwatch alarm for my s3 bucket, if there are no changes to the bucket in a day, the alarm is triggered and an SNS topic is sent.
I have set a cloudwatch event rule to schedule the target SNS topic daily if it meets the conditions.
However, I am having trouble customizing the SNS message needed to provided detail to the notifications.
I have attempted to use the input transformer, but I cannot wrap my head around keys I need to map for this service.
How can I map the details required? How can I find the key-value details to send to my Input Transformer to formulate a message?
The easiest method would be to trigger an AWS Lambda function that can read the incoming information, customize the content, and then send it as a message through Amazon SNS.
I don't think Amazon CloudWatch can directly trigger an AWS Lambda function, so you'll probably need two SNS topics:
One SNS topic used by CloudWatch, that triggers the Lambda function
One SNS topic that where Lambda sends the customized message and people can subscribe to receive it
The Lambda function can also do additional work, such as reporting on the size of the bucket and retrieving additional stats you would like mentioned.

How to secure Firebase Messaging topics with cloud functions?

Is there a way to secure validate subscriptions to topics? For example, is it possible to limit topic Test to a specific user with ID XXXXX? Is this possible with Cloud Functions?
firebaser here
To be able to subscribe to a topic, you currently need to know two things: the FCM token/instance ID of the app instance, and the path/name of the topic to subscribe to.
Knowing these two allows one to subscribe to the topic from any client. There currently is no public API to limit who can subscribe to what topics. So if you need to guarantee that the message is only delivered to authorized app instances, you should not use topics and instead delivery to each FCM token/instance ID directly from your own (server-side) code.
This request comes along regularly though, so I recommend that you file a feature request to add your vote.

Can I subscribe a topic to another topic in Firebase Cloud Messaging

Is there a way to subscribe a existing topic to new topic in Firebase Cloud Messaging, so that all the registered clients of old topic will be registered to new topic.
Example: If I have a FCM topic name A and I create a new FCM topic B. Can I add topic A to topic B?
No, only client apps can determine which topics they want to subscribe to in order to receive messages. You can't route messages going to a topic through another topic. What you would have to do instead is program the server side code that sends the message to send to multiple topics as needed.

Amazon Simple Notification Service to http endpoint

I want to send message from Amazon Simple Notification Service(SNS) to the http endpoint. There is no proper solid documentation on how to do that. Though I had read Amazon SNS documentation still I could not get entire picture.
Can anyone give me simple example on how Amazon SNS and http endpoint work together?
There good documentation for what you asking: http://docs.aws.amazon.com/sns/latest/dg/sns-dg.pdf
Look at the page #147, it describes what steps you need to do for sending messages to HTTP(s) endpoint.
Also check this example which describes how to create topic, subscribe endpoint, confirm subscription and start to receive notification messages from SNS (uses Java SDK): https://github.com/mfine/AmazonSNSExample
General picture is:
On the publisher side:
create topic and subscribe some endpoint to receive messages. After subscribing endpoint to topic, the endpoint will receive SubscriptionConfirmation message.
start publish to topic so your endpoints will receive notification messages
On the subscriber side (your endpoint should be able to handle at least confirm subscription request and notification messages):
confirm subscription: make HTTP GET request to the "SubscribeURL" URL which comes inside the body of the confirm subscription request. Before you confirm subscription your endpoint will not receive any messages from SNS
receive notification messages and do what you want

Resources