ASSESSMENT FOR Lab - Design
and Manage Pub/Sub
Messaging with Amazon Simple
Notification Service (SNS)
Objective 1: Configure message filtering policies in
Amazon SNS to control message delivery to
subscribers
1. Define Message Attributes
When publishing a message to an SNS topic, include message
attributes (key-value pairs) that describe the message. For example:
json
Copy
{
"category": "Electronics",
"price": 99.99,
"availability": "InStock"
}
2. Create Filter Policies
Filter policies are JSON documents that define conditions based on message
attributes. Attach these policies to subscribers to control message delivery.
Basic Filtering
Exact Match:
json
, Copy
{
"category": ["Electronics"]
}
Delivers messages where category is "Electronics".
Multiple Values (OR logic):
json
Copy
{
"category": ["Electronics", "Books"]
}
Delivers messages where category is "Electronics" or "Books".
Advanced Filtering
Numeric Comparisons:
json
Copy
{
"price": [{"numeric": ["<", 100]}]
}
Delivers messages where price is less than 100.
Logical Operators (AND/OR/NOT):
json
Copy
{
"AND": [
{"category": ["Electronics"]},
{"OR": [
{"price": [{"numeric": ["<", 100]}]},