Development with AWS Services

An SNS topic publishes JSON messages containing a region field but no message attributes. An SQS subscription should receive only messages whose region is eu-west-1; which configuration meets this requirement without changing publishers?

Show the answer

Correct answerC. Set the subscription filter scope to MessageBody and filter on region.

AWhy not this: Raw message delivery removes the SNS envelope but does not select messages by their contents.

BWhy not this: MessageAttributes filtering evaluates message attributes, which these publishers do not supply.

CWhy this is right: MessageBody filtering lets an SNS subscription match the region field directly in the JSON payload.

DWhy not this: An SQS access policy controls authorization; it does not filter SNS deliveries by arbitrary JSON body fields.

SNS payload-based filtering uses the MessageBody scope to evaluate fields in a JSON message body. MessageAttributes filtering cannot match the region because the publisher supplies no message attributes.