Easy ReviewSAA-C03
Design Resilient Architectures19

SNS

Publish to multiple subscribers, filter each delivery path, and protect SNS-to-SQS delivery and recovery.

Amazon SNS connects event publishers to application and human subscribers. Subscription filters select messages; queue policies, encryption permissions, and dead-letter queues govern each delivery path.

Topics, subscriptions, and fan-out

Amazon SNS is a publish/subscribePublish/subscribe sends messages through a topic to recipients attached by subscriptions. service: a publisher sends a message to a topicA topic is a named communication channel to which publishers send messages., and subscriptionsA subscription connects a topic to an endpoint that receives its messages. connect that topic to recipient endpointsAn endpoint is the destination that receives an SNS notification.. Fan-outFan-out delivers one publication to multiple subscribers. means delivering a publication to several independent subscribers.

How it works

  1. Choose a topic type and attach subscriptions for the recipients. Standard topics can deliver duplicates and messages out of publication order, so applications must handle both.

    Destination on a Standard topic Use
    SQS Retain messages for later processing
    Lambda Run application logic
    HTTP or HTTPS Send to a web endpoint
    Email Notify people
    SMS Notify a phone number by text
    Mobile push Notify a mobile application
    Data Firehose Send events to a delivery stream
  2. Confirm email and HTTP(S) subscriptions before expecting notifications. HTTP(S) endpoints must accept SNS POST requests, including subscription confirmation.

  3. Publish to the topic. SNS pushes to subscribers; SQS consumers pollPolling asks a queue for messages waiting to be processed., meaning they ask the queue for waiting messages. Separate queues let independent applications retain and process their own copies.

  4. For ordered processing, combine an SNS FIFOFIFO preserves message order within each message group when used with FIFO delivery destinations. topic with an SQS FIFO queue. FIFO means first in, first out. Set MessageGroupId to identify events whose order must be preserved. Ordering applies within a group.

  5. For deployment notifications, configure a CodeDeploy deployment-group event trigger to send events, including failures, to an SNS topic.

Exam cues

  • If the question says every application needs an independent copy and can be temporarily offline, think SNS with one SQS queue per application, because each queue retains its delivered messages.
  • If the question says deployment failure email without polling, think a native CodeDeploy trigger to SNS, because the deployment group can emit the event directly.
  • If the question says an email subscription receives nothing, think confirmation, because SNS waits for the recipient to confirm.
  • If the question says an EC2 instance should subscribe to an SNS topic, think Lambda, SQS or HTTPS subscribers instead, because an instance is not an SNS subscription type.

Remember

  • SNS pushes; SQS consumers poll.
  • Standard topics: at-least-once delivery and best-effort ordering.
  • SNS FIFO can deliver to Standard queues, but strict consumer ordering requires FIFO queues.
  • FIFO topics do not directly support email, HTTP(S), SMS, or mobile push.
  • FIFO topics store messages across multiple Availability Zones.
  • SSEServer-side encryption protects stored message contents using an encryption key. encrypts message bodies only, with symmetric KMS keys.
  • Delivery status logging covers endpoints such as SQS, Lambda, Firehose and HTTP/S.

Trap: An SNS FIFO topic alone cannot preserve ordered processing through an SQS Standard queue. Choose a FIFO queue when consumer ordering matters.

One publication, separate subscriber queues
publish1copy A2copy B3PublisheriSNS topiciConsumer A queueiConsumer B queuei
  1. The publisher sends one message to SNS.

  2. SNS pushes the message to the first subscribed queue.

  3. SNS also pushes the message to the other subscribed queue; each application polls its own queue.

Box details (4)
Publisher

A publisher sends a message to the topic.

SNS topic

SNS pushes a copy to each matching subscription.

Consumer A queue

The queue retains messages for its application to poll later.

Consumer B queue

A separate subscription delivers to a separate queue for the other application.

From the AWS docs (19)
  • SNS asynchronously delivers messages from publishers to subscribers through topics.
  • SNS Standard topic destinations include SQS, Lambda, HTTP(S), email, SMS, mobile push, and Data Firehose.
  • SNS pushes notifications; SQS retains messages for applications to process later through polling.
  • A topic can deliver a published message to multiple subscribed SQS queues.
  • Email subscriptions must be confirmed before receiving messages and are supported directly only on Standard topics.
  • HTTP(S) endpoints must handle SNS POST requests and confirm the subscription before notifications arrive.
  • SNS FIFO topics deliver to SQS FIFO and Standard queues; strict consumer ordering requires a FIFO queue.
  • SNS FIFO topics cannot directly deliver to email, HTTP(S), SMS, or mobile push endpoints; Lambda integration uses a subscribed SQS queue.
  • SNS FIFO publishers set MessageGroupId; ordering is maintained within each message group.
  • CodeDeploy deployment-group triggers send deployment events, including failures, to an SNS topic.
  • SNS Standard topics provide at-least-once delivery and best-effort ordering, so duplicates and out-of-order messages can occur.
  • SNS subscription endpoint types are HTTP/HTTPS, email, Amazon SQS, AWS Lambda, Amazon Data Firehose, platform application endpoints (mobile push) and SMS; an EC2 instance is not an endpoint type of its own.
  • AWS End User Messaging SMS, the former SMS, MMS and voice features of Amazon Pinpoint, is an application-to-person messaging service for SMS, MMS, RCS and voice.
  • With two-way SMS, AWS End User Messaging SMS receives incoming replies from customers, which can feed services such as Lambda or Amazon Lex.
  • SNS topics accept messages up to 256 KiB by default; the MaximumMessageSize topic attribute raises this to 1 MiB, and topics above 256 KiB support Firehose, SQS and Lambda subscriptions.
  • An SNS FIFO topic accepts but does not deliver a message whose deduplication ID was already published within the five-minute deduplication interval.
  • SNS FIFO topics and SQS queues store messages redundantly across multiple Availability Zones.
  • SNS server-side encryption encrypts message bodies with symmetric KMS keys only; topic metadata and message metadata such as subject, ID and attributes are not encrypted.
  • SNS can log the delivery status of messages to endpoints such as Amazon SQS, AWS Lambda, Data Firehose and HTTP/S.

Subscription filters

An SNS subscriptionA subscription connects a topic to an endpoint that receives its messages. filter selects messages before delivery to that subscriber. A message attributeA message attribute is a named metadata value published alongside the message body. is named metadata sent alongside the payloadA payload is the application data carried inside a message., while the message body is the payload itself.

How it works

  1. Attach a JSON filter policyA filter policy selects which messages SNS delivers to a particular subscription. to the subscription that needs a subset of messages. Subscriptions without a policy receive every publication.

  2. Select the filter scope: MessageAttributes is the default; MessageBody inspects a well-formed JSON payload.

  3. Define the properties and accepted values. Each named policy property must match, and at least one accepted value must match for each property. Extra message properties do not affect the result.

  4. Choose operators that express the selection.

    Match type Use
    Exact string A particular named value
    Prefix or suffix A string beginning or ending with a selected value
    Anything-but A value outside an excluded selection
    Numeric match A number matching the chosen condition
  5. SNS delivers matching messages to that subscription and omits nonmatches.

Exam cues

  • If the question says a routing field is inside the JSON payload, think MessageBody, because the default scope looks at attributes.
  • If the question says different subscribers need different event categories, think subscription filter policies, because each subscription selects its own messages.

Remember

  • Default scope: MessageAttributes.
  • Body scope: MessageBody, requiring a well-formed JSON object.
  • All named policy properties must match; values within a property provide alternatives.

Trap: Creating a filter for a body field while leaving the default scope unchanged does not make SNS inspect the body.

From the AWS docs (9)
  • Without a filter policy, an SNS subscription receives every message published to its topic.
  • A filter policy is a JSON object attached to a subscription that selects which messages SNS sends to that subscriber.
  • FilterPolicyScope defaults to MessageAttributes.
  • FilterPolicyScope: MessageBody applies filtering to message-body properties.
  • Message-body filtering assumes the payload is a well-formed JSON object.
  • Each policy property must match a corresponding message attribute or body property, with at least one matching value per property.
  • Message attributes or body properties not specified in the filter policy are ignored during evaluation.
  • SNS filtering supports exact string matching, prefixes, suffixes, anything-but, numeric matching, and other documented operators.
  • SNS does not deliver a message to a subscription when it fails that subscription filter.

Flashcards

tap to flip
Answer

·

All 19 cards as a list

What do an Amazon SNS topic and subscription represent?

A topic is the publication channel. A subscription connects a recipient endpoint to that channel for message delivery.

Two independent applications must each receive every SNS event and process it when ready. What design should the team use?

Subscribe a separate SQS queue for each application to the SNS topic. SNS fans out messages and SQS retains them for each application to poll.

An SNS Standard topic must notify people and trigger applications. Which destination types can it use?

SQS, Lambda, HTTP(S), email, SMS, mobile push, and Data Firehose.

An SNS email subscription exists but receives no messages. What subscription step should be checked first?

Confirmation. The recipient must confirm the email subscription before receiving notifications.

Can an SNS FIFO topic directly notify an email address or HTTP endpoint?

No. Those direct endpoints require Standard topics. For Lambda processing from FIFO topics, use a subscribed SQS queue as the function event source.

An SNS workflow needs consumer ordering for events belonging to each customer. Which topic, queue, and field fit?

Use an SNS FIFO topic with an SQS FIFO queue and assign MessageGroupId by customer. Ordering is within each message group.

A team needs email when a CodeDeploy deployment fails, without adding a polling function. How can SNS be used?

Configure a failure-event trigger on the CodeDeploy deployment group with an SNS topic, and confirm the email subscription.

An SNS Standard subscriber receives a duplicate message and another message out of publication order. Is this outside the topic delivery contract?

No. Standard topics provide at-least-once delivery and best-effort ordering. Subscriber applications must be able to process duplicates and out-of-order messages.

A team wants an EC2 instance to subscribe directly to an SNS topic so it can react to alarm notifications. Is that possible?

No. SNS delivers to SQS, Lambda, HTTP or HTTPS, email, SMS, mobile push and Data Firehose, not to an instance. Subscribe a Lambda function or an SQS queue the instance polls.

Can an Amazon EC2 instance subscribe to an SNS topic directly?

Not as an endpoint type. SNS delivers to HTTP/HTTPS, email, SQS, Lambda, Firehose, mobile push and SMS; an app on EC2 would expose an HTTP endpoint or read from an SQS queue.

An application publishes events that several independent workers must process at their own pace. How can Amazon SNS and Amazon SQS support this?

Subscribe a separate SQS queue for each worker to an SNS topic. SNS fans out each message, and the queues retain messages for later polling.

A publisher must send 700 KiB messages through an SNS topic to SQS and Lambda subscribers. Is S3 offloading required?

Not necessarily. Set the topic MaximumMessageSize attribute, up to 1 MiB. The default is 256 KiB, and larger topics support Firehose, SQS and Lambda subscriptions.

An Amazon SNS topic uses server-side encryption. Is a sensitive value placed in a message attribute protected?

No. SSE encrypts the message body only; message attributes, subject and topic metadata stay unencrypted.

A team must confirm whether Amazon SNS messages reached an SQS queue and a Lambda function. Which SNS feature helps?

Delivery status logging for those endpoints.

An SNS subscriber needs only messages matching attributes or body content. What should the team configure?

A subscription filter policy. It evaluates MessageAttributes by default; set FilterPolicyScope to MessageBody for a well-formed JSON body.

An SNS message contains a routing field only inside its JSON body, but the subscription filter still uses the default scope. What should change?

Set FilterPolicyScope to MessageBody. The default MessageAttributes scope does not inspect body fields.

An SNS subscription filter names region and severity. The message matches severity but not region. Will SNS deliver it?

No. Each policy property must match, with at least one matching value for every property.

Does an additional SNS message attribute absent from the subscription filter make the message fail filtering?

No. SNS ignores properties that the policy does not specify.

What does an SNS subscription receive if no filter policy is assigned?

Every message published to its topic, subject to successful delivery.

You finished every topic of SAA-C03!

Your badge turned gold. Next step: book the exam on AWS. Once you pass, add yourself to Who passed.

Share

Share that you finished this certification

I finished every topic of AWS Certified Solutions Architect - Associate (SAA-C03) on Easy Review. Come study too!