← Week 1: Messaging: SQS, SNS, EventBridge

Day 7: Challenge — Event-Driven Pipeline

Phase 5 · Aug 18, 2026

← Week 1: Messaging: SQS, SNS, EventBridge

Challenge Overview

Build an event-driven order processing pipeline on AWS.

Architecture:

[Order API (Lambda + API GW)]
       ↓ PutEvents
[EventBridge custom bus]
       ↓ Rule: source=com.myapp.orders
  ┌────┴────────┬──────────────────┐
  ↓             ↓                  ↓
[SQS: payments] [SQS: inventory] [Lambda: notifications]
  ↓             ↓
[Lambda: charge] [Lambda: reserve]
  ↓ on failure
[DLQ: payments-dlq]
← Week 1: Messaging: SQS, SNS, EventBridge

Requirements

  1. Order API: Lambda function receives HTTP POST, validates, publishes to EventBridge
  2. EventBridge rule: route order.placed events to payments SQS + inventory SQS + notification Lambda
  3. Payments Lambda: simulate charge (90% success, 10% failure); batch item failure reporting
  4. Inventory Lambda: simulate reservation; idempotent using DynamoDB conditional write
  5. DLQs: configured with CloudWatch alarms
  6. Infrastructure: CloudFormation template for all resources
← Week 1: Messaging: SQS, SNS, EventBridge

CloudFormation Skeleton

Resources:
  OrderEventBus:
    Type: AWS::Events::EventBus
    Properties: { Name: order-events }

  PaymentsQueue:
    Type: AWS::SQS::Queue
    Properties:
      RedrivePolicy:
        maxReceiveCount: 3
        deadLetterTargetArn: !GetAtt PaymentsDLQ.Arn

  OrderRule:
    Type: AWS::Events::Rule
    Properties:
      EventBusName: !Ref OrderEventBus
      EventPattern:
        source: ["com.myapp.orders"]
        detail-type: ["order.placed"]
      Targets:
        - Id: payments
          Arn: !GetAtt PaymentsQueue.Arn
        - Id: inventory
          Arn: !GetAtt InventoryQueue.Arn
        - Id: notifications
          Arn: !GetAtt NotificationFunction.Arn
← Week 1: Messaging: SQS, SNS, EventBridge

Test Scenarios

# Submit 10 test orders
for i in $(seq 1 10); do
    aws apigateway test-invoke-method \
        --rest-api-id $API_ID \
        --resource-id $RESOURCE_ID \
        --http-method POST \
        --body "{\"order_id\":\"order-$i\",\"amount\":$((RANDOM % 1000))}"
done

# Verify DLQ is empty (all payments succeeded or retried successfully)
aws sqs get-queue-attributes \
    --queue-url $PAYMENTS_DLQ \
    --attribute-names ApproximateNumberOfMessages

# Check CloudWatch logs for all Lambda functions
aws logs tail /aws/lambda/payments-processor --follow
← Week 1: Messaging: SQS, SNS, EventBridge

Week 1 Recap

Service Role
SQS Standard Background task queuing, at-least-once
SQS FIFO Ordered processing, deduplication
SNS Fan-out: one event → many consumers
EventBridge Event routing from AWS services + custom events
Lambda + ESM Serverless consumers with auto-scaling

Next week: DynamoDB internals — the data model, capacity planning, and advanced patterns.