
Building a Simple Event Driven Architecture on AWS
A simple serverless, event-driven AWS architecture where API requests are received through API Gateway, queued in SQS, processed by Lambda, and stored in DynamoDB. DynamoDB Streams detects changes and triggers another Lambda, which publishes events through SNS to multiple downstream systems. It demonstrates decoupling, scalability, asynchronous processing, and event-driven communication.
When I was learning how to design solutions on AWS, one of the architectures I came across used a small set of AWS managed services to build an event-driven application.
It is a relatively simple architecture, but it demonstrates several important AWS concepts: API-driven applications, asynchronous processing, serverless compute, NoSQL databases, database streams, and event notifications.
The architecture uses:
Amazon API Gateway → Amazon SQS → AWS Lambda → Amazon DynamoDB → DynamoDB Streams → AWS Lambda → Amazon SNS → Multiple Systems
The Architecture
At a high level, the flow looks like this:
Client │ ▼API Gateway │ ▼SQS │ ▼Lambda │ ▼DynamoDB │ ▼DynamoDB Streams │ ▼Lambda │ ▼SNS │ ├──► System 1 ├──► System 2 └──► System 3The interesting part is that the application is not processing everything in one synchronous request. Instead, work is passed between services using queues and events.
1. API Gateway — Receiving the Request
The first component is Amazon API Gateway.
Imagine we are building an e-commerce application where customers can place orders.
A customer sends:
POST /orderswith something like:
{ "customerId": "123", "productId": "ABC", "quantity": 2}API Gateway receives this HTTP request and passes the information into the backend architecture.
The important thing is that API Gateway doesn't need to perform all the processing itself.
It can simply accept the request and pass the work to the next component.
2. SQS — Holding the Work
The request is placed into Amazon SQS.
This introduces an important concept: decoupling.
Instead of doing this:
User → API → Processing → Database → Notificationsduring one request, we do:
User → API → SQSand the rest happens asynchronously.
Why is this useful?
Imagine that suddenly thousands of customers place orders at the same time.
The SQS queue can temporarily hold the messages:
Order 1Order 2Order 3Order 4...Order 10,000The backend can process them at its own pace.
SQS therefore acts as a buffer between the API and the processing system.
It also improves reliability because a temporary problem with the processing component doesn't necessarily mean the incoming work is immediately lost.
3. Lambda — Processing the Messages
Next, AWS Lambda consumes messages from SQS.
Lambda retrieves an order from the queue and executes the application logic.
For example:
SQS ↓Lambda ↓Validate order ↓Process order ↓Store orderThe advantage is that we don't need to maintain servers just to process these messages.
Lambda automatically creates execution environments as needed and can process multiple messages concurrently, subject to the configured concurrency and event-source behavior.
This gives us a completely serverless processing layer.
4. DynamoDB — Storing the Data
After processing the order, Lambda stores the information in Amazon DynamoDB.
For example:
Orders Table
Order ID Customer Product Quantity------------------------------------------------1001 123 ABC 21002 456 XYZ 1DynamoDB is a managed NoSQL database designed for highly scalable applications.
At this point, the architecture has accomplished the main job:
Client ↓API Gateway ↓SQS ↓Lambda ↓DynamoDBBut there is another interesting requirement.
What if other systems need to know that an order was created?
That's where DynamoDB Streams comes in.
5. DynamoDB Streams — Detecting Changes
DynamoDB Streams keeps a time-ordered record of item-level changes in a DynamoDB table.
For example, when Lambda creates:
Order 1001in DynamoDB, the change can appear in the DynamoDB Stream.
Conceptually:
DynamoDB │ ▼DynamoDB Streams │ ▼"Order 1001 was created"This means we don't have to modify our original API request just to notify other systems.
The database change itself becomes an event that can trigger further processing.
6. Another Lambda — Processing the Event
A second Lambda function consumes events from DynamoDB Streams.
Its job could be something like:
DynamoDB Stream ↓ Lambda ↓Create notification event ↓ SNSFor example, the Lambda might transform the DynamoDB change into:
{ "event": "OrderCreated", "orderId": "1001", "customerId": "123"}It then publishes this event to Amazon SNS.
Notice that this is a different Lambda function from the one that originally processed the order.
That's intentional.
Each component has a focused responsibility.
7. SNS — Broadcasting the Event
Now we reach Amazon SNS (Simple Notification Service).
SNS is useful when multiple systems need to receive the same event.
For example:
SNS / | \ / | \ ▼ ▼ ▼ System 1 System 2 System 3Suppose an order has been created.
Different systems might need to react to it:
- An inventory system updates stock.
- A notification system sends an email.
- An analytics system records the event.
Instead of our Lambda having to communicate individually with every system, it publishes one event to SNS.
SNS handles the fan-out.
Putting Everything Together
Let's walk through a complete example.
Imagine a customer purchases two laptops.
Step 1 — Customer places an order
Customer ↓API GatewayThe customer sends the order through an API.
Step 2 — API puts the request into SQS
API Gateway ↓SQSThe order is now safely waiting to be processed.
Step 3 — Lambda processes the order
SQS ↓LambdaLambda reads the message and performs the required business logic.
Step 4 — Lambda stores the order
Lambda ↓DynamoDBThe order is saved in the database.
Step 5 — DynamoDB generates a stream event
DynamoDB ↓DynamoDB StreamsThe database change is captured by the stream.
Step 6 — Second Lambda processes the event
DynamoDB Streams ↓LambdaThis Lambda creates an
OrderCreated event.Step 7 — SNS broadcasts the event
Lambda ↓SNSSNS publishes the event to its subscribers.
Step 8 — Multiple systems react
SNS / | \ ▼ ▼ ▼ Inventory Email AnalyticsAll three systems can independently react to the same order event.
Why This Architecture Is Useful
The real value of this architecture isn't the individual services. It's how the services work together.
Decoupling
SQS separates the API from the processing system.
The API doesn't need to know how the order will ultimately be processed.
Scalability
Lambda can process messages concurrently, while SQS can absorb temporary traffic spikes.
Reliability
If the downstream processing system temporarily struggles, messages can remain in SQS instead of requiring the API to keep the client waiting.
Event-driven design
DynamoDB Streams allows database changes to trigger additional processing without tightly coupling everything together.
Fan-out
SNS allows one event to be delivered to multiple subscribing systems.
The Bigger Lesson
The biggest thing I took away from this architecture while learning AWS was that you don't have to build everything into one application or one server.
Instead, you can combine small, managed AWS services:
API Gateway ↓ SQS ↓ Lambda ↓ DynamoDB ↓DynamoDB Streams ↓ Lambda ↓ SNS ↓Multiple SystemsEach service has a specific responsibility, and events connect the different parts of the system.
This is the foundation of serverless and event-driven architecture on AWS.
And that's what makes this seemingly simple architecture a great starting point for understanding how much more sophisticated AWS systems can be built.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article