Lab - Design and Manage
Pub/Sub Messaging with
Amazon Simple Notification
Service (SNS)
Task 5: Challenge - Advanced SNS Message Filtering (Optional)
This challenge involves designing and implementing complex filter
policies for Amazon SNS subscriptions using logical operators,
numerical comparisons, and attribute existence checks. Below is a
structured guide with all possible questions and answers to help
you master advanced filtering scenarios.
Step 1: Define Message Attributes
Messages must include attributes for filtering. Example attributes:
json
Copy
{
"priority": "high",
"service": "payment",
"severity_level": 7,
"environment": "prod",
"debug_flag": true
}
Step 2: Create Advanced Filter Policies
Use JSON filter policies to define conditions for subscribers.
Example 1: Logical AND/OR
, Deliver messages
where priority=high AND (service=payment OR service=auth):
json
Copy
{
"priority": ["high"],
"service": ["payment", "auth"]
}
Example 2: Numeric Comparisons
Deliver messages where severity_level > 5:
json
Copy
{
"severity_level": [{"numeric": [">", 5]}]
}
Example 3: Existence Check
Deliver messages that include the debug_flag attribute (regardless
of value):
json
Copy
{
"debug_flag": [{"exists": true}]
}
Example 4: Range Check
Deliver messages where severity_level is between 3 and 7:
json
Copy
{
"severity_level": [{"numeric": [">=", 3, "<=", 7]}]
Pub/Sub Messaging with
Amazon Simple Notification
Service (SNS)
Task 5: Challenge - Advanced SNS Message Filtering (Optional)
This challenge involves designing and implementing complex filter
policies for Amazon SNS subscriptions using logical operators,
numerical comparisons, and attribute existence checks. Below is a
structured guide with all possible questions and answers to help
you master advanced filtering scenarios.
Step 1: Define Message Attributes
Messages must include attributes for filtering. Example attributes:
json
Copy
{
"priority": "high",
"service": "payment",
"severity_level": 7,
"environment": "prod",
"debug_flag": true
}
Step 2: Create Advanced Filter Policies
Use JSON filter policies to define conditions for subscribers.
Example 1: Logical AND/OR
, Deliver messages
where priority=high AND (service=payment OR service=auth):
json
Copy
{
"priority": ["high"],
"service": ["payment", "auth"]
}
Example 2: Numeric Comparisons
Deliver messages where severity_level > 5:
json
Copy
{
"severity_level": [{"numeric": [">", 5]}]
}
Example 3: Existence Check
Deliver messages that include the debug_flag attribute (regardless
of value):
json
Copy
{
"debug_flag": [{"exists": true}]
}
Example 4: Range Check
Deliver messages where severity_level is between 3 and 7:
json
Copy
{
"severity_level": [{"numeric": [">=", 3, "<=", 7]}]