This lesson combines 3 topics: Amazon SQS, Amazon SNS, Amazon EventBridge.
Learning Objectives
- Understand SQS: managed message queue
- Distinguish Standard vs FIFO queues
- Master visibility timeout, DLQ, long polling
- Apply the decoupling pattern with SQS
- Understand SNS: managed pub/sub messaging
- Distinguish Topic types: Standard vs FIFO
- Master subscription protocols and message filtering
- Apply the fanout pattern (SNS + SQS)
- Understand EventBridge: the event bus for event-driven architecture
- Distinguish Default vs Custom vs Partner Event Bus
- Master Rules, Targets, Schema Registry
- Apply cron schedules and cross-account events
Part 1: Amazon SQS
1. SQS Overview
Amazon SQS (Simple Queue Service) = fully managed message queue service for decoupling distributed components.
Characteristics
- Pull-based (consumers poll)
- At-least-once delivery (Standard) / Exactly-once (FIFO)
- Highly available: messages replicated across multiple AZs
- Scalable: handle 100K+ messages/sec (Standard)
- Message size: up to 1 MiB (since 08/2025; the exam may still use the old 256 KB; use S3 for larger)
- Retention: 1 minute - 14 days (default 4 days)
Use cases
- Decouple components (producer ≠ consumer rate)
- Buffer for traffic spikes
- Async processing (orders, emails, image processing)
- Task scheduling (delayed messages)
2. SQS Queue Types
Standard Queue
- At-least-once delivery (may deliver duplicate)
- Best-effort ordering (not strict FIFO)
- Unlimited throughput (auto-scale)
- Most use cases
FIFO Queue
- Exactly-once processing
- Strict FIFO ordering (per Message Group)
- 300 messages/sec (without batching), 3000/sec with batching; with high-throughput mode, up to 70,000 TPS per API (region-dependent)
- Higher cost (~$0.50/M vs $0.40/M)
- Queue name must end with
.fifo
When to use FIFO
- Financial transactions (order matters)
- Sequential events processing
- Banking ledger
- Exactly-once required (no dedup logic in app)
When to use Standard
- High throughput needed
- Order doesn't matter (independent tasks)
- Lower cost
3. Producer
Send Message
sqs.send_message(
QueueUrl='https://sqs.us-east-1.amazonaws.com/111/MyQueue',
MessageBody='{"order_id": "123", "amount": 99.99}',
DelaySeconds=10, # delay before consumers can receive
MessageAttributes={...}
)
Send Message Batch
- Up to 10 messages in 1 call
- Reduces cost (1 API call vs 10)
- Total batch size ≤ 1 MiB (old limit: 256 KB)
4. Consumer
Poll Messages
response = sqs.receive_message(
QueueUrl='...',
MaxNumberOfMessages=10, # 1-10
WaitTimeSeconds=20, # long polling
VisibilityTimeout=30
)
for msg in response.get('Messages', []):
process(msg['Body'])
# MUST delete after processing
sqs.delete_message(
QueueUrl='...',
ReceiptHandle=msg['ReceiptHandle']
)
Consumers
- EC2 instances (often in ASG)
- Lambda functions (Event Source Mapping → poll automatically)
- ECS / Fargate
- On-prem servers
Auto-scaling consumers
- ASG scale based on CloudWatch metric
ApproximateNumberOfMessagesVisible - Lambda scale automatically (up to concurrency limit)
5. Visibility Timeout
Definition
Visibility Timeout = period during which a received message is hidden from other consumers.
Workflow
1. Consumer A: ReceiveMessage → message hidden from others
2. Visibility Timeout starts (default 30s)
3. Consumer A processes message
4. Consumer A: DeleteMessage → message removed
5. (Or) If A fails to delete within timeout → message visible again, another consumer can receive
Configuration
- Default: 30 seconds
- Range: 0 to 12 hours
- Set per queue or per message (override)
Best practice
- Set timeout = average processing time × 2-3 (safety margin)
- Long-running tasks: extend timeout with the
ChangeMessageVisibilityAPI - Short tasks: short timeout (faster retry on failure)
Common issue: duplicate processing
- Consumer A processes message but slow
- Timeout expires before A deletes
- Message reappears → Consumer B receives same message
- → Both A and B process duplicate
- Solution: idempotent processing OR extend visibility timeout
6. Long Polling vs Short Polling
Short Polling (default)
WaitTimeSeconds = 0- Returns immediately (even if no messages)
- More API calls → more cost
- Higher latency for low-traffic queues
Long Polling (recommended)
WaitTimeSeconds = 1-20- Wait up to N seconds for messages to arrive
- Fewer API calls → lower cost
- Lower latency
Setup
- Set
ReceiveMessageWaitTimeSecondsat queue level (default polling) - Or override per
ReceiveMessagecall
7. Dead Letter Queue (DLQ)
Definition
DLQ = secondary queue for messages that failed processing N times.
Workflow
1. Message delivered to consumer
2. Consumer fails to process (exception, timeout)
3. Message reappears, retry
4. After N retries (Max Receive Count), message moves to DLQ
5. DLQ alerts via CloudWatch → investigate
Configuration
RedrivePolicy:deadLetterTargetArn: ARN of DLQmaxReceiveCount: e.g., 3 (after 3 failed processing, move to DLQ)
DLQ best practices
- Set up CloudWatch alarm on DLQ message count
- Manually inspect DLQ for failure pattern
- Fix bug → redrive messages back to source queue (DLQ Redrive)
Use case
- Poison messages (malformed data)
- App bug processing certain message types
- External service downtime causing retries
8. Message Lifecycle
9. SQS Security
Access Control
- IAM policies (identity-based)
- SQS Queue Policy (resource-based, cross-account)
Encryption
- In transit: TLS
- At rest: SQS-managed encryption or KMS
- Enable per queue
VPC Endpoint
- Interface Endpoint for SQS (PrivateLink)
- Private subnets access SQS without going over the internet
10. SQS Advanced Features
Delay Queues
- Delay messages 0-15 minutes before visible to consumers
- Set per queue (default 0)
Message Timers
- Per-message delay (override queue default)
- Up to 15 minutes
FIFO Specific Features
- MessageGroupId: group messages, FIFO within group
- MessageDeduplicationId: dedupe within 5-minute window
- Multiple Groups can process in parallel
Long Messages (> 1 MiB)
- Use SQS Extended Client Library: store payload in S3, queue contains S3 reference
- Or use Step Functions with larger payload support
11. SQS vs SNS vs EventBridge
| SQS | SNS | EventBridge | |
|---|---|---|---|
| Type | Queue (point-to-point) | Topic (pub/sub) | Event Bus (pub/sub + routing) |
| Consumers | 1 consumer per message | Many subscribers per message | Many targets with filtering |
| Delivery | Pull (consumer polls) | Push to subscribers | Push to targets |
| Use case | Decouple, async work | Fanout notifications | Event-driven architecture |
Combined pattern: SNS + SQS fanout
Each consumer processes independently from their queue.
12. SQS Pricing
- $0.40 per million requests (Standard)
- $0.50 per million requests (FIFO)
- Free tier: 1M requests/month
- No data transfer charge within same Region (to EC2)
Optimization
- Batch operations (10 messages/call = 10x cost reduction)
- Long polling (fewer empty polls)
- Right-size visibility timeout
13. Common Patterns
Pattern 1: Order processing
Web app → SQS Queue → Order Processor (EC2 ASG)
→ DLQ if processing fails
Pattern 2: Image thumbnail generation
User upload → S3 → SNS → SQS → Lambda → resize → S3
Pattern 3: Email batch sending
App → SQS FIFO Queue (group by user)
→ Worker reads, sends email via SES
Pattern 4: Job retry mechanism
App → SQS (initial)
→ Lambda → 3 retries
→ DLQ → CloudWatch alarm → Ops investigation
Part 2: Amazon SNS
1. SNS Overview
Amazon SNS (Simple Notification Service) = fully managed pub/sub messaging service.
Characteristics
- Push-based (vs SQS pull-based)
- Fanout: 1 message → multiple subscribers
- Multiple protocols: HTTP/S, Email, SMS, Lambda, SQS, mobile push, Kinesis Firehose
- Highly scalable: millions of messages/sec
- Does not store messages (unlike SQS's 14-day retention): SNS only has a delivery retry policy (HTTP/S with backoff); messages that cannot be delivered are discarded unless you configure a DLQ (SQS queue). Need a durable buffer → fan out to SQS. This SNS/SQS distinction is a frequent exam question!
Use cases
- Application notifications (email, SMS)
- Fanout to multiple SQS queues
- Lambda triggers
- Mobile push notifications (iOS, Android, Fire OS)
- CloudWatch alarm notifications
2. Topic Types
Standard Topic
- At-least-once delivery
- Best-effort ordering
- Unlimited throughput
- All subscription types supported
FIFO Topic
- Exactly-once delivery
- Strict ordering (per Message Group)
- 300 publishes/sec (without batching)
- Subscribers: SQS queues only (FIFO or Standard) — no email, SMS, HTTP; Lambda must go through an SQS queue
- Topic name must end with
.fifo
When FIFO
- Need ordering across messages
- Need exactly-once
- Trade-off: lower throughput, limited subscriber types
3. Subscription Protocols
| Protocol | Use case |
|---|---|
| HTTP / HTTPS | Webhook to your endpoint |
| Email / Email-JSON | Send notification to email |
| SMS | Send text message to phone (charged per SMS) |
| SQS | Fanout to SQS queue |
| Lambda | Invoke Lambda function |
| Application (mobile push) | iOS APNs, Android FCM, Fire OS ADM, Baidu, WNS, MPNS |
| Amazon Data Firehose (formerly Kinesis Data Firehose) | Stream to S3, Redshift, OpenSearch |
| SMS to 200+ countries | Direct SMS |
Subscription confirmation
- For HTTP/email: subscriber must confirm subscription (click link / verify)
- Prevents spam
4. Fanout Pattern (SNS + SQS)
Architecture
Benefits
- 1 publish → N consumers (no publisher rewrite)
- Each consumer independent (own queue, own processing rate)
- Add/remove consumers without affecting publisher
- Each queue can have own DLQ, own visibility timeout
Use case examples
- E-commerce order placed → Email notification + Update inventory + Trigger analytics
- File upload to S3 → Generate thumbnail + Index for search + Send notification
Setup
- Create an SNS Topic
- Create multiple SQS queues
- Subscribe each queue to topic
- Configure SQS access policy allowing SNS to publish
5. Message Filtering
Definition
Message Filtering = subscribers receive only messages matching filter policy (instead of all).
Filter Policy (subscriber-level)
{
"event_type": ["order_placed", "order_shipped"],
"amount": [{ "numeric": [">=", 100] }],
"country": [{ "anything-but": ["US"] }]
}
Use case
- 1 topic for all events, subscribers pick relevant ones
- Reduce processing for irrelevant messages
- Simpler architecture than multiple topics
Example
6. SNS Security
Access Control
- IAM policies (identity-based)
- SNS Topic Policy (resource-based, cross-account)
Encryption
- In transit: TLS
- At rest: KMS encryption
VPC Endpoint
- Interface Endpoint for SNS
- Private subnet publish to SNS
Message data protection (NEW)
- Detect/mask PII in SNS messages (similar to Macie)
7. Mobile Push Notifications
Supported platforms
- APNs (Apple Push Notification Service) - iOS
- FCM (Firebase Cloud Messaging) - Android
- ADM (Amazon Device Messaging) - Fire OS
- WNS (Windows Push) - Windows
- MPNS (Microsoft Push Notification) - Windows Phone (legacy)
- Baidu Cloud Push - Android China
Workflow
1. App registers with platform (APNs/FCM)
2. App sends device token to your backend
3. Backend creates "endpoint" in SNS for device
4. SNS endpoint added to topic (or directly published)
5. Publish to topic → SNS forwards to APNs/FCM → device
8. SNS with Amazon Data Firehose
Integration (2023+)
- SNS subscribe to Amazon Data Firehose delivery stream
- Stream messages to:
- S3
- Redshift
- OpenSearch
- HTTP endpoint
- 3rd party (Splunk, Datadog)
Use case
- Centralize event logging from SNS to S3 data lake
- Real-time analytics with OpenSearch
9. SNS vs SQS vs EventBridge (deep)
| SNS | SQS | EventBridge | |
|---|---|---|---|
| Model | Pub/Sub | Queue | Event Bus + Routing |
| Subscribers | Push to all | Pull by 1 | Push to all matching rules |
| Filtering | Yes (subscription) | No (consumer filter) | Yes (rules) |
| Sources | Producers | Producers | AWS services, custom, SaaS |
| Targets | HTTP, email, SMS, SQS, Lambda, mobile, Firehose | EC2, Lambda, Fargate (poll) | 25+ AWS services |
| Retry | Built-in | Visibility timeout + DLQ | Built-in + DLQ |
| Use case | Fanout, notifications | Decouple async work | Event-driven architecture |
Decision guide
- Notify multiple subscribers: SNS
- Decouple producer-consumer pace: SQS
- Route AWS events to targets with filtering: EventBridge
- Combo: SNS for fanout, SQS for each subscriber queue, EventBridge for AWS-native events
10. SNS Pricing
- $0.50 per million publishes (Standard)
- $1.00 per million publishes (FIFO)
- HTTP deliveries: $0.60 per million
- Email: $2.00 per 100K (US)
- SMS: per message + country-specific (~$0.00645/SMS in US)
- Lambda invocations: free (Lambda billed separately)
- SQS delivery: free (SQS billed separately)
- Mobile push: $0.50 per million
Free tier
- 1M publishes/month
- 100,000 HTTP deliveries
- 1,000 emails
- 1M mobile push
11. Common Patterns
Pattern 1: Order processing fanout
Pattern 2: Multi-channel alerts
Pattern 3: Mobile app push
Pattern 4: Event filtering
Part 3: Amazon EventBridge
1. EventBridge Overview
Amazon EventBridge (formerly CloudWatch Events) = serverless event bus that routes events from AWS services, custom apps, and SaaS to targets.
Characteristics
- Schema-based events (JSON structured)
- Filter + route events based on rules
- Multi-source: AWS services, custom apps, SaaS partners
- Multi-target: 25+ AWS services
- Cross-account, cross-region event routing
- Replay events (debugging, reprocessing)
- Schema Registry for event discovery
Use cases
- Event-driven architecture
- Cron-based scheduling (replace cron servers)
- React to AWS service events (EC2 state change, S3 upload)
- SaaS integration (Datadog, Zendesk, Shopify, MongoDB)
- Cross-account event sharing
2. EventBridge Components
Event Bus
- Container for events
- 3 types:
- Default Event Bus: AWS service events go here automatically
- Custom Event Bus: for your custom apps' events
- Partner Event Bus: events from SaaS partners (Zendesk, etc.)
Event
- JSON structured message
- Standard fields:
source,detail-type,detail,time,region,account
Rule
- Filter events based on:
- Event source/detail-type
- Event content (JSON pattern matching)
- Route matched events to targets
Target
- Destination for matched events
- 25+ types: Lambda, SQS, SNS, Step Functions, Kinesis, EC2, Glue, ...
3. Event Structure
{
"version": "0",
"id": "abc123",
"detail-type": "EC2 Instance State-change Notification",
"source": "aws.ec2",
"account": "111111111111",
"time": "2025-01-15T10:00:00Z",
"region": "us-east-1",
"resources": [
"arn:aws:ec2:us-east-1:111111111111:instance/i-12345"
],
"detail": {
"instance-id": "i-12345",
"state": "running"
}
}
Standard AWS Service Events
- EC2: instance state change, terminate, stop
- S3: object created, deleted (must enable)
- CodeCommit: push to repo
- CloudTrail: any API call (subset of API events)
- RDS: snapshot complete
- Auto Scaling: launch, terminate
- ECS: task state change
- Health: AWS health events
- Trusted Advisor: check status change
4. Rules and Patterns
Pattern matching examples
Match EC2 instance running state
{
"source": ["aws.ec2"],
"detail-type": ["EC2 Instance State-change Notification"],
"detail": {
"state": ["running"]
}
}
Match S3 upload to specific bucket
{
"source": ["aws.s3"],
"detail-type": ["Object Created"],
"detail": {
"bucket": {
"name": ["my-bucket"]
}
}
}
Match specific account API call (CloudTrail)
{
"source": ["aws.iam"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventName": ["CreateUser", "DeleteUser"]
}
}
Operators
exists,equals-ignore-case,prefix,suffixnumeric:["=", 5],[">", 100]anything-but: excludecidr: IP range matching
5. Targets (25+ types)
| Target | Use case |
|---|---|
| Lambda | Custom processing |
| SQS | Queue for async processing |
| SNS | Fanout to subscribers |
| Step Functions | Workflow orchestration |
| Kinesis | Stream processing |
| EC2 Run Command | Automation |
| EC2 Action (stop, terminate, reboot) | EC2 management |
| Glue Job | ETL trigger |
| CodePipeline | CI/CD trigger |
| API Destinations (HTTP endpoint) | Webhook to external system |
| Batch Job | Batch compute trigger |
| ECS Task | Container task |
| EventBridge Event Bus (cross-account, cross-region) | Forward events |
Multiple targets
- 1 rule → up to 5 targets
- Each target can have own input transformation
Input Transformation
- Modify event JSON before sending to target
- Use case: target API expects different format
6. Schedule (Cron-based Events)
Replaced traditional cron
- Old way: EC2 cron job
- New way: EventBridge Scheduler (rate or cron expression)
Expressions
rate(5 minutes) → every 5 minutes
rate(2 hours) → every 2 hours
cron(0 12 * * ? *) → daily at 12:00 UTC
cron(0 8 ? * MON-FRI *) → Mon-Fri 8 AM UTC
cron(0/30 * * * ? *) → every 30 min
Use cases
- Periodic Lambda execution
- Daily reports
- Database cleanup
- Health checks
EventBridge Scheduler (newer, 2022+)
- Dedicated scheduler service
- More features: one-time schedule, flexible time windows, dead-letter queue
- Recommended for new schedules
7. Schema Registry
Definition
Schema Registry = discover and manage event schemas.
Characteristics
- Auto-discover schemas from events on the event bus
- Browse + search schemas
- Generate code bindings (Java, Python, TypeScript) for type-safe event handling
- Versioning of schemas
Use case
- Developer productivity (autocomplete in IDE)
- Type safety in code
- Document events for team
8. Cross-Account Events
Setup
- Sender account: Create rule, target = event bus ARN of receiver account
- Receiver account: Custom event bus, resource policy allowing sender account
- Sender publishes → events forwarded to receiver
Use case
- Centralized event hub (security account receives all events)
- Multi-account SaaS
9. Replay Events
Definition
Archive + Replay = save events to archive, replay later for debugging/reprocessing.
Setup
- Create Archive for event bus
- Archive stores events (configurable retention)
- Replay events to bus → reprocess by rules
Use cases
- Debug after fix (replay events that failed before)
- Add new consumer post-hoc
- Disaster recovery (replay events lost during outage)
10. SaaS Integrations
Partner Event Bus
- AWS partners stream events to your account via Partner Event Source
- Examples:
- Auth0: user events
- Datadog: monitoring events
- MongoDB Atlas: DB events
- Shopify: order events
- PagerDuty: incident events
- Stripe: payment events
- Zendesk: ticket events
Setup
- Subscribe to partner in EventBridge console
- Partner creates Event Source → you create Event Bus from source
- Define rules → route to your targets
11. EventBridge Pipes (2022+)
Definition
Pipes = point-to-point integration between a source and a target with optional filtering/enrichment.
Architecture
Difference from Event Bus
- Pipes: 1 source → 1 target (point-to-point)
- Event Bus: N sources → N targets (event hub)
Use case
- Replace simple Lambda triggers
- Built-in batching, filtering, enrichment
- No code for simple integrations
12. EventBridge vs SNS
| EventBridge | SNS | |
|---|---|---|
| Model | Event bus (rule-based) | Pub/Sub topic |
| Sources | AWS services + custom + SaaS | Custom only |
| Filtering | Powerful (JSON pattern) | Basic (attributes) |
| Targets | 25+ types | 10+ types |
| Replay | Yes | No |
| Schema Registry | Yes | No |
| Scheduler | Yes (cron) | No |
| Use case | AWS-native events, complex routing | Notifications, fanout |
Decision
- AWS service events: EventBridge (native)
- Custom app fanout to many subscribers: SNS or EventBridge
- Need filtering, routing logic: EventBridge
- Simple notifications: SNS
13. Pricing
EventBridge
- $1 per million events published to custom/partner bus
- AWS service events to default bus: FREE
- Cross-account: charged at sender
- Archive storage: $0.10/GB-month
- Replay: $1/M events
Schedule
- 14M invocations/month free
- $1 per M after
14. Common Patterns
Pattern 1: Auto-tag EC2 on launch
EC2 instance launch event
→ EventBridge rule (match RunInstances)
→ Lambda: add tags based on launching user
Pattern 2: Replace cron
EventBridge Scheduler (cron 0 2 * * ? *)
→ Lambda: daily database cleanup
Pattern 3: Cross-account audit
Account A, B, C → CloudTrail events → EventBridge
→ Forward to Security Account event bus
→ Lambda: log to S3, alert on suspicious activity
Pattern 4: SaaS integration
Zendesk ticket created
→ Partner Event Bus
→ EventBridge rule
→ Lambda → create Slack notification + update CRM
Review Questions
-
What is the core difference between Standard and FIFO queues?
Show answer
Standard: high throughput (nearly unlimited), at-least-once delivery (duplicates possible), best-effort ordering (not guaranteed). FIFO: limited throughput (300 msg/s, or 3000 with batching), exactly-once delivery (automatic deduplication), guaranteed ordering (FIFO). FIFO queue names end with
.fifo. Use FIFO for financial transactions and order processing — where strict ordering is required; use Standard for high-throughput async jobs. -
What is the default visibility timeout in seconds?
Show answer
30 seconds (default). Range: 0 seconds to 12 hours. When a consumer receives a message, the message is "invisible" to other consumers for the visibility timeout — preventing duplicate processing. If the consumer finishes processing → it deletes the message. If the timeout expires before deletion → the message becomes visible again and another consumer can receive it. Consumers should set the visibility timeout > max processing time to avoid duplicates.
-
How does long polling differ from short polling?
Show answer
Short polling (default): returns immediately even if the queue is empty — causing many empty API responses and wasted cost. Long polling (
WaitTimeSeconds1-20s): SQS waits until a message arrives or the timeout expires before responding — fewer empty responses, lower cost, lower latency. AWS recommends long polling (20 seconds) for production. SetReceiveMessageWaitTimeSecondsat the queue level or per request. -
What problem does a DLQ solve?
Show answer
A Dead Letter Queue (DLQ) stores messages that could not be processed successfully after N retries (
maxReceiveCount). It prevents "poison pill messages" from blocking the queue forever. A DLQ is a normal Standard/FIFO queue — you can inspect, debug, or reprocess its messages. Usually you set up an alarm on DLQ metrics to alert on failures. The DLQ must be the same type (Standard/FIFO) as the source queue. -
What is the maximum number of messages in 1 SendMessage batch?
Show answer
10 messages per batch (SendMessageBatch API). The total batch size is at most 1 MiB (the old limit was 256 KB — the exam may still use it). Batching reduces the number of API calls and cost (billed per request, not per message). Similarly, ReceiveMessage can receive up to 10 messages per call, and DeleteMessageBatch can delete up to 10 messages. Use batching to optimize throughput and cost.
-
Is SNS push or pull?
Show answer
Push — SNS actively pushes messages to subscribers as soon as they are published. Unlike SQS (pull model — consumers must poll). SNS subscribers receive messages immediately without polling. This is the pub/sub model: the publisher publishes once, and SNS fans out to many subscribers at the same time.
-
What is the subscriber type restriction for a FIFO topic?
Show answer
A FIFO SNS topic only delivers to SQS queues — SQS FIFO (keeps strict ordering and deduplication) or SQS Standard (best-effort ordering, at-least-once, cheaper). You cannot subscribe email, SMS, mobile push, or HTTP(S) endpoints to a FIFO topic; to fan out to Lambda, subscribe an SQS queue and let the queue trigger the function. A Standard topic supports all subscriber types. Older materials/exams say "SQS FIFO only" — if there is no "SQS Standard" option, pick SQS FIFO.
-
What problem does the fanout pattern with SNS + SQS solve?
Show answer
It allows one message to be processed independently by many consumers. Example: order placed → SNS topic → (1) SQS queue for the inventory service, (2) SQS queue for the notification service, (3) SQS queue for analytics. Each service has its own queue — it can scale and fail independently. If one service is down, messages wait in its SQS queue — nothing is lost. This is the strongest decoupling pattern for microservices.
-
Is message filtering set at the topic or subscription level?
Show answer
Subscription level — each subscription can have its own filter policy. The filter policy is based on message attributes (key-value metadata in the message). A subscriber only receives messages that match the filter — reducing processing and cost. Example: subscription A filters
{"type": ["order"]}, subscription B filters{"type": ["payment"]}— same topic, but each subscriber only receives relevant messages. -
Does SNS support mobile push notifications? Which platforms?
Show answer
Yes — SNS is the standard platform for mobile push. It supports: APNs (Apple Push Notification service — iOS/macOS), FCM/GCM (Firebase Cloud Messaging — Android), ADM (Amazon Device Messaging — Kindle), Baidu Cloud Push (China Android). You configure a platform application with credentials from the platform. SNS handles authentication with the push platforms — no separate code per platform.
- Which events does the EventBridge default event bus contain?
Show answer
The default event bus receives AWS service events (EC2 state changes, S3 object create, RDS snapshots, CodePipeline state changes, GuardDuty findings...). You cannot delete the default event bus. Custom event buses are created separately for application events. Partner event buses receive events from SaaS partners (Zendesk, Datadog, PagerDuty...). Rules filter events and route them to targets.
- What is the maximum number of targets per rule?
Show answer
5 targets per rule. Each rule can fan out to 5 services at once (Lambda, SQS, SNS, Step Functions, API Gateway, Kinesis, ECS, SSM...). If you need to fan out to more than 5 targets, use an SNS topic as 1 target and fan out from SNS. EventBridge supports 300+ AWS services and SaaS partners as targets.
- When do you use EventBridge Pipes instead of Rules?
Show answer
EventBridge Pipes is for point-to-point integration with transformation: one source (SQS, DynamoDB Streams, Kinesis, Kafka) → optional filtering → optional enrichment (Lambda, Step Functions, API GW) → one target. A good fit when you need to transform data in the pipeline. Rules are for broadcast: one event → many targets, complex filtering. Pipes simplify patterns that used to require a lot of Lambda glue code.
- Can EventBridge schedule cron jobs?
Show answer
Yes — EventBridge Scheduler (and legacy CloudWatch Events scheduled rules) lets you schedule by: cron expression (UTC) or rate expression (for example rate(5 minutes)). EventBridge Scheduler (2022) is a separate, improved service: flexible time windows, timezone support, retry with DLQ, millions of schedules. Use it to trigger Lambda, Step Functions, ECS tasks, SQS, API calls on a schedule.
- What does Schema Registry help developers do?
Show answer
Schema Registry documents and discovers event schemas (the structure of JSON events) in EventBridge. It automatically infers schemas from events, or you can define them manually. Benefits: (1) Code bindings — generate TypeScript/Java/Python classes from a schema, (2) Discovery — teams know which events are available without contacting each other, (3) Validation — verify events conform to the schema before processing. Similar to Swagger/OpenAPI but for event-driven systems.
Hands-on Exercises
Part 1: Amazon SQS
- Create a Standard SQS queue, send 10 messages, receive a batch of 10
- Create a FIFO queue, test ordering with MessageGroupId
- Set up a DLQ, force the consumer to fail, observe the message moving to the DLQ
- Configure long polling 20s, observe the API call reduction
- Set up a Lambda trigger from SQS (Event Source Mapping)
- Test SQS Extended Client for a message > 1 MiB
Part 2: Amazon SNS
- Create a Standard SNS Topic
- Subscribe an email, confirm the subscription, test publish
- Fanout: 1 topic → 3 SQS queues, publish 1 message, verify all 3 received it
- Add a message filter to 1 subscription, test that filtering works
- Set up CloudWatch alarm → SNS → email
- (Optional) Mobile push setup with FCM
Part 3: Amazon EventBridge
- Create a rule: EC2 instance state change → SNS notification
- Create an EventBridge Schedule that runs Lambda every 5 minutes
- Set up a cross-account event: from Account A → Account B's bus
- Browse Schema Registry, generate a code binding for 1 event
- Create a Pipe: SQS → Lambda with filtering
References
- Amazon SQS Documentation
- FIFO Queues
- Visibility Timeout
- DLQ
- Amazon SNS Documentation
- SNS Subscription Filter Policies
- Fanout Pattern
- Mobile Push
- EventBridge Documentation
- Event Patterns
- Schedule Expressions
- EventBridge Pipes
- Schema Registry