Monday, October 3, 2016

AWS CDA Study List - SNS

SNS

Basics

  • Basically a system to send messages based on actions and triggers
  • Uses PUSH -mechanism
  • Supports message sending in following formats
    • HTTP / HTTPS
    • Email / Email-JSON
    • SQS
    • SMS
  • Can be used with other services such as EC2, S3 and SQS
  • Can be used to "fan-out" SQS -messages
  • SNS message will contain following in JSON format
    • MessageID
    • Timestamp
    • TopicArn
    • Type
    • UnsubscribeURL
    • Message
    • Subject
    • Signature
    • SignatureVersion

Limits

  • Topic name is limited to 256 characters
  • Maximum 10 million subscribers per topic
  • Maximum 100,000 topics per account
  • SNS message can contain maximum 256KB of text data, including XML, JSON and unformatted text

Following topics are exam questions collected through Internet and should be evaluated as so. Answers are mine and have been checked with answers collected through the internet, but might still be wrong.


SNS delivery formats


Which of the following are valid SNS delivery transports? Choose 2 answers

A. SMS
B. DynamoDB
C. HTTP
D. UDP
E. Named Pipes

Why? 

https://aws.amazon.com/sns/faqs/?nc1=h_ls

Q: What are the different delivery formats/transports for receiving notifications?

In order for customers to have broad flexibility of delivery mechanisms, Amazon SNS supports notifications over multiple transport protocols. Customers can select one the following transports as part of the subscription requests:

  • “HTTP”, “HTTPS” – Subscribers specify a URL as part of the subscription registration; notifications will be delivered through an HTTP POST to the specified URL.
  • ”Email”, “Email-JSON” – Messages are sent to registered addresses as email. Email-JSON sends notifications as a JSON object, while Email sends text-based email.
  • “SQS” – Users can specify an SQS queue as the endpoint; Amazon SNS will enqueue a notification message to the specified queue (which subscribers can then process using SQS APIs such as ReceiveMessage, DeleteMessage, etc.)
  • “SMS” – Messages are sent to registered phone numbers as SMS text messages.

SNS Publish


Which of the following are valid arguments for an SNS Publish request? Choose 3 answers

A. Subject
B. Language
C. Message
D. Destination
E. TopicArn
F. Format

Why? 

http://docs.aws.amazon.com/sns/latest/api/API_Publish.html

Message
The message you want to send to the topic.

MessageAttributes , MessageAttributes.entry.N.Name (key), MessageAttributesentry.N.Value (value)
Message attributes for Publish action.

MessageStructure
Set MessageStructure to json if you want to send a different message for each protocol. For example, using one publish action, you can send a short message to your SMS subscribers and a longer message to your email subscribers. If you set MessageStructure to json, the value of the Message parameter must:

PhoneNumber
The phone number to which you want to deliver an SMS message. Use E.164 format.

Subject
Optional parameter to be used as the "Subject" line when the message is delivered to email endpoints. This field will also be included, if present, in the standard JSON messages delivered to other endpoints.

TargetArn
Either TopicArn or EndpointArn, but not both.

TopicArn
The topic you want to publish to.


SNS API calls


You are providing AWS consulting services for a company developing a new mobile application that will be leveraging Amazon SNS Mobile Push for push notifications. In order to send direct notification messages to individual devices each device registration identifier or token needs to be registered with SNS; however the developers are not sure of the best way to do this. You advise them to:

A. Call the CreatePlatformEndPoint API function to register multiple device tokens.
B. Bulk upload the device tokens contained in a CSV file via the AWS Management Console.
C. Let the push notification service (e.g. Amazon Device Messaging) handle the registration.
D. Implement a token vending service to handle the registration.

Why?

http://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-devicetoken.html

When you first register an app and mobile device with a notification service, such as Apple Push Notification Service (APNS) and Google Cloud Messaging for Android (GCM), device tokens or registration IDs are returned from the notification service. When you add the device tokens or registration IDs to Amazon SNS, they are used with the PlatformApplicationArn API to create an endpoint for the app and device. When Amazon SNS creates the endpoint, an EndpointArn is returned. The EndpointArn is how Amazon SNS knows which app and mobile device to send the notification message to.

You can add device tokens and registration IDs to Amazon SNS using the following methods:

  • Manually add a single token to AWS using the AWS Management Console
  • Migrate existing tokens from a CSV file to AWS using the AWS Management Console
  • Upload several tokens using the CreatePlatformEndpoint API
  • Register tokens from devices that will install your apps in the future

SNS Message formats

What is the format of structured notification messages sent by Amazon SNS?

A. An XML object containing MessageId, UnsubscribeURL, Subject, Message and other values
B. An JSON object containing MessageId, DuplicateFlag, Message and other values
C. An XML object containing MessageId, DuplicateFlag, Message and other values
D. An JSON object containing MessageId, unsubscribeURL, Subject, Message and other values

Why? 

http://docs.aws.amazon.com/sns/latest/dg/json-formats.html

HTTP/HTTPS Notification JSON Format

When Amazon SNS sends a notification to a subscribed HTTP or HTTPS endpoint, the POST message sent to the endpoint has a message body that contains a JSON document with the following name/value pairs.

Message
The Message value specified when the notification was published to the topic.

MessageId
A Universally Unique Identifier, unique for each message published. For a notification that Amazon SNS resends during a retry, the message ID of the original message is used.

Signature
Base64-encoded "SHA1withRSA" signature of the Message, MessageId, Subject (if present), Type, Timestamp, and TopicArn values.

SignatureVersion
Version of the Amazon SNS signature used.

SigningCertURL
The URL to the certificate that was used to sign the message.

Subject
The Subject parameter specified when the notification was published to the topic. Note that this is an optional parameter. If no Subject was specified, then this name/value pair does not appear in this JSON document.

Timestamp
The time (GMT) when the notification was published.

TopicArn
The Amazon Resource Name (ARN) for the topic that this message was published to.

Type
The type of message. For a notification, the type is Notification.

UnsubscribeURL
A URL that you can use to unsubscribe the endpoint from this topic. If you visit this URL, Amazon SNS unsubscribes the endpoint and stops sending notifications to this endpoint.

The following HTTP POST message is an example of a Notification message to an HTTP endpoint.

No comments:

Post a Comment