How do you diagram a serverless AWS architecture (Lambda, API Gateway, DynamoDB) in Mermaid?
Diagram a serverless AWS stack in Mermaid architecture-beta: why Lambda, API Gateway, DynamoDB, S3, and Cognito sit at the Region level with no VPC, the request path to draw, and the one VPC-attached Lambda exception.
In a serverless AWS diagram the services — Lambda, API Gateway, DynamoDB, S3, Cognito — are all regional and managed, so each sits directly inside the Region group, not inside a VPC or subnet. Draw the request path API Gateway to Lambda to DynamoDB. Only place a Lambda in a private subnet when it is VPC-attached to reach private resources.
Serverless architectures break the habit every AWS diagram teaches you. You spend months drawing VPCs, subnets, NAT gateways, and load balancers, and then you build an API on Lambda, API Gateway, and DynamoDB — and suddenly there is no VPC to draw, no subnet to place things in, and no network path to trace. The instinct is to reach for the familiar box-in-a-box layout anyway, wrapping the Lambda in a VPC because that is what "an AWS diagram" looks like. That instinct produces a wrong picture.
A serverless diagram is a different kind of drawing: it shows the path a request or event takes through a set of managed, regional services, not the network those services live in. This post covers where each serverless service belongs, the one case where a Lambda really does go in a subnet, and two worked examples — a synchronous REST API and an event-driven flow — each validated at zero rule violations. If you have not set up architecture-beta with AWS icons yet, start with how to draw AWS architecture diagrams in Mermaid and the architecture-beta syntax reference.
Serverless AWS services are regional and managed — Lambda, API Gateway, DynamoDB, S3, and Cognito all sit directly inside the Region, not inside a VPC or a subnet. The diagram is a request path, not a network: API Gateway → Lambda → DynamoDB. The one exception is a VPC-attached Lambda, which must live in a private subnet. Draw it that way and it validates at zero violations in LatixEngine.
What makes a serverless AWS architecture different to diagram?
The defining property of a serverless service is that AWS owns the infrastructure it runs on. You do not place a Lambda function on a subnet the way you place an EC2 instance, because there is no instance and no subnet you control — the function runs in AWS-managed capacity inside the Region. The same is true of API Gateway, DynamoDB, S3, Cognito, EventBridge, SQS, and SNS. They are all regional services: scoped to a Region, reached through a regional endpoint, and living outside any VPC.
That single fact changes the shape of the diagram. A three-tier or VPC networking diagram is dominated by containment — a VPC holding subnets holding instances, with route tables deciding what can talk to the internet. A serverless diagram has almost none of that. The containment is shallow: an AWS Account, a Region, and then a flat set of services inside it. What carries the meaning is the edges — the direction a request flows from the client through API Gateway to a function to a table.
This is why copying a VPC layout onto a serverless system produces something misleading. Wrapping a Lambda and a DynamoDB table inside a VPC box implies a network boundary that does not exist and hides the thing that actually matters: the invocation path.
Where do Lambda, API Gateway, and DynamoDB sit in the diagram?
Every core serverless service is a direct child of the Region. There is no intermediate VPC or subnet layer for managed regional services — placing one inside a VPC or subnet is a placement error, and a validator will flag it. Here are the pieces and their Mermaid slugs.
| Service | Role in a serverless app | Where it sits | Mermaid slug |
|---|---|---|---|
| API Gateway | Public HTTP front door | Region | aws:arch-amazon-api-gateway |
| Lambda | Compute / business logic | Region (managed) | aws:arch-aws-lambda |
| DynamoDB | Primary data store | Region | aws:arch-amazon-dynamodb |
| S3 | Object storage / static assets | Region | aws:arch-amazon-simple-storage-service |
| Cognito | Authentication / user pool | Region | aws:arch-amazon-cognito |
| EventBridge | Event bus | Region | aws:arch-amazon-eventbridge |
| SQS | Queue | Region | aws:arch-amazon-simple-queue-service |
| SNS | Pub/sub topic | Region | aws:arch-amazon-simple-notification-service |
The pattern is uniform: service <id>(aws:<slug>)[Label] in region. For the full icon set, see the icon catalog; for the grammar of the in clause and port-anchored edges, the architecture-beta syntax reference.
Does Lambda go inside a VPC or a subnet?
This is the one place the "everything at Region level" rule bends, and it is worth being precise. A Lambda function has two modes:
- Not VPC-attached (the default). The function runs in AWS-managed infrastructure and can reach public AWS service endpoints — DynamoDB, S3, other APIs — directly. It has no network placement of its own, so on the diagram it sits at the Region level. This is the right default for most serverless apps, and it is what both examples below use.
- VPC-attached. When a function needs to reach a private resource — an RDS database, an ElastiCache cluster, something in a private subnet — you attach it to the VPC. Its elastic network interfaces then live in subnets, and AWS requires those to be private subnets only. On the diagram, a VPC-attached Lambda must be drawn inside a private subnet, never a public one and never loose in the VPC.
That second case is the only serverless placement rule with teeth, and it is the exact mirror of the private-instance rule from the VPC networking guide:
architecture-beta
group account(aws:aws-account)[AWS Account]
group region(aws:region)[us-east-1] in account
group vpc(aws:virtual-private-cloud-vpc)[VPC] in region
group priv(aws:private-subnet)[Private Subnet] in vpc
service fn(aws:arch-aws-lambda)[VPC-Attached Lambda] in priv
service rds(aws:arch-amazon-rds)[RDS PostgreSQL] in priv
fn:R --> L:rdsIf you draw a VPC-attached Lambda in a public subnet, or leave it sitting directly in the VPC, LatixEngine flags it — the same way it catches a database in a public subnet. Unless a function genuinely needs private resources, leave it out of the VPC entirely; attaching it for no reason adds cold-start latency and a diagram box that misrepresents how the function actually runs.
What does a serverless REST API look like in Mermaid?
The canonical serverless stack is a synchronous REST API: a client calls API Gateway, which authorizes the request against a Cognito user pool and invokes a Lambda function, which reads and writes DynamoDB and serves assets from S3. Every service is a direct child of the Region, and the diagram is the request path.
architecture-beta
service users(aws:res-users-light)[Users]
group account(aws:aws-account)[AWS Account]
group region(aws:region)[us-east-1] in account
service cognito(aws:arch-amazon-cognito)[Cognito User Pool] in region
service apigw(aws:arch-amazon-api-gateway)[API Gateway] in region
service fn(aws:arch-aws-lambda)[Lambda Function] in region
service ddb(aws:arch-amazon-dynamodb)[DynamoDB Table] in region
service s3(aws:arch-amazon-simple-storage-service)[Assets S3] in region
users:R --> L:apigw
apigw:B --> T:cognito
apigw:R --> L:fn
fn:R --> L:ddb
fn:B --> T:s3Notice what is not there: no VPC, no subnets, no NAT gateway, no load balancer. A region holding nothing but managed services is a completely valid AWS architecture, and the diagram is honest about it. The edges do the explaining — the request enters at API Gateway, gets authorized, runs in Lambda, and persists to DynamoDB. For this same shape as one of a set of copy-paste starting points, see the serverless entry in the AWS architecture patterns gallery.
How do you diagram an event-driven serverless flow?
Serverless systems are rarely just request/response. The pattern that makes them scale is asynchronous fan-out: a function accepts work, drops an event onto EventBridge or a queue, and a separate worker processes it later. Mermaid handles this cleanly because directional edges read as the flow of events.
architecture-beta
service users(aws:res-users-light)[Users]
group account(aws:aws-account)[AWS Account]
group region(aws:region)[us-east-1] in account
service apigw(aws:arch-amazon-api-gateway)[API Gateway] in region
service ingest(aws:arch-aws-lambda)[Ingest Lambda] in region
service bus(aws:arch-amazon-eventbridge)[EventBridge] in region
service queue(aws:arch-amazon-simple-queue-service)[SQS Queue] in region
service worker(aws:arch-aws-lambda)[Worker Lambda] in region
service ddb(aws:arch-amazon-dynamodb)[DynamoDB Table] in region
users:R --> L:apigw
apigw:R --> L:ingest
ingest:R --> L:bus
bus:R --> L:queue
queue:R --> L:worker
worker:R --> L:ddbThe ingest path stays fast because it just publishes an event; the slow work happens in the worker on its own schedule. Read left to right, the diagram tells that story directly — which is the whole point of drawing it. Everything is still region-level, so the picture stays flat and the flow stays legible.
How do you keep a serverless diagram correct?
Serverless diagrams fail quietly in a specific way: because the layout is so flat, a wrong placement does not look wrong. A Lambda accidentally wrapped in a VPC, a DynamoDB table nested inside a subnet, or an API Gateway drawn under a VPC all render as tidy boxes — they just describe an architecture that cannot exist. That is exactly the class of error a validator is for.
- Keep managed services at the Region level. API Gateway, DynamoDB, S3, and Cognito are regional; if a diagram nests them in a VPC or subnet, it is wrong, and LatixEngine flags each one.
- Only VPC-attach a Lambda when it needs private resources, and then only in a private subnet. Everything else is a non-VPC function at Region level.
- Commit the .mmd text next to the function code it describes, so the diagram diffs in the same pull request as the change. For the anti-patterns this shares with server-based designs, see common AWS architecture mistakes; for turning an existing template or model into this shape with an LLM, see how to prompt LLMs for Mermaid AWS diagrams.
LatixEngine is free, runs entirely in the browser with no login or install, and checks every icon slug against the catalog and every placement against AWS rules — so a serverless diagram that renders cleanly is also one that is actually correct.
Frequently asked questions
Do Lambda functions go inside a VPC in an architecture diagram?
By default, no. A Lambda function runs on AWS-managed infrastructure and does not belong to your VPC, so in most serverless diagrams it sits directly at the Region level with no VPC around it. You only attach a Lambda to a VPC when it must reach private resources like an RDS database — and in that case it must be drawn inside a private subnet, never a public one.
Where does API Gateway sit in a serverless diagram — inside a VPC?
API Gateway is a regional, fully managed service, so it sits directly inside the Region group, not inside a VPC or subnet. It is the public front door of the architecture: clients hit API Gateway, and it invokes your Lambda functions. Drawing it inside a VPC or subnet is a placement error that a validator will flag.
How do you show DynamoDB in a serverless Mermaid diagram?
DynamoDB is a regional service that lives outside any VPC, so it is drawn as a direct child of the Region group, beside API Gateway and Lambda rather than inside a subnet. Lambda connects to it directly over the AWS network. If your compute is inside a VPC and needs private access to DynamoDB, add a gateway VPC endpoint in the same Region rather than moving the table into the VPC.
What AWS icon slugs do you use for Lambda, API Gateway, and DynamoDB in Mermaid?
Use aws:arch-aws-lambda for Lambda, aws:arch-amazon-api-gateway for API Gateway, and aws:arch-amazon-dynamodb for DynamoDB. Common companions are aws:arch-amazon-cognito (Cognito), aws:arch-amazon-eventbridge (EventBridge), aws:arch-amazon-simple-queue-service (SQS), and aws:arch-amazon-simple-storage-service (S3). All of these are region-level service icons.
Can Mermaid draw an event-driven or asynchronous serverless architecture?
Yes. Model each service as a node and each event hop as an edge: API Gateway to an ingest Lambda, the Lambda to EventBridge or an SQS queue, then a worker Lambda to DynamoDB. Because architecture-beta edges are directional, the diagram reads as the flow of events rather than a network topology, which is exactly how a serverless system is best explained.
Is a serverless diagram different from a VPC or three-tier diagram?
Fundamentally, yes. A VPC diagram is about network containment — subnets, route tables, NAT and internet gateways. A serverless diagram is about a request or event path between managed regional services, with almost no network boxes at all. The containment is shallow (Account, Region, then services), and the meaning lives in the edges, not the nesting.
Paste any example in this post into the LatixEngine editor to render it with native cloud icons and validate it against AWS, Azure, and GCP best practices. No login, no install.
Open the editor →