Back to Home
Documentation

Reference

Examples and Use Cases

Representative DAC patterns for serverless, networking, application, and AI-driven workflows.

Common patterns

PatternBest fit
Single resourceS3 bucket, Lambda, or DynamoDB reference diagram
Network topologyVPC, subnets, ALB, NAT, IGW, and service placement
Application platformECS or Lambda services with data and messaging layers
Multi-regionReplicated services or failover topology
AI-generated diagramHuman prompt -> MCP -> DAC YAML -> PNG or draw.io

Serverless worker pipeline

yaml
Diagram:
  DefinitionFiles:
    - Type: URL
      Url: "https://raw.githubusercontent.com/fernandofatech/diagram-as-code/main/definitions/definition-for-aws-icons-light.yaml"
  Resources:
    Canvas:
      Type: AWS::Diagram::Canvas
      Children: [Cloud]
    Cloud:
      Type: AWS::Diagram::Cloud
      Preset: AWSCloudNoLogo
      Children: [App, Queue, Worker]
    App:
      Type: AWS::Lambda::Function
      Title: API Lambda
    Queue:
      Type: AWS::SQS::Queue
    Worker:
      Type: AWS::Lambda::Function
      Title: Worker Lambda
  Links:
    - Source: App
      Target: Queue
      TargetArrowHead:
        Type: Open
    - Source: Queue
      Target: Worker
      TargetArrowHead:
        Type: Open

Frontend + API + data stack

yaml
Diagram:
  DefinitionFiles:
    - Type: URL
      Url: "https://raw.githubusercontent.com/fernandofatech/diagram-as-code/main/definitions/definition-for-aws-icons-light.yaml"
  Resources:
    Canvas:
      Type: AWS::Diagram::Canvas
      Direction: vertical
      Children: [Users, Cloud]
    Users:
      Type: AWS::Diagram::HorizontalStack
      Children: [Web, Mobile]
    Web:
      Type: AWS::Diagram::Resource
      Preset: User
      Title: Web User
    Mobile:
      Type: AWS::Diagram::Resource
      Preset: Mobile client
    Cloud:
      Type: AWS::Diagram::Cloud
      Preset: AWSCloudNoLogo
      Direction: vertical
      Children: [Api, Data]
    Api:
      Type: AWS::Diagram::HorizontalStack
      Children: [Gateway, Service]
    Gateway:
      Type: AWS::ApiGateway
      Title: Public API
    Service:
      Type: AWS::Lambda::Function
      Title: Orders Service
    Data:
      Type: AWS::Diagram::HorizontalStack
      Children: [Redis, Database]
    Redis:
      Type: AWS::ElastiCache::CacheCluster
    Database:
      Type: AWS::RDS::DBCluster
  Links:
    - Source: Web
      Target: Gateway
      TargetArrowHead:
        Type: Open
    - Source: Mobile
      Target: Gateway
      TargetArrowHead:
        Type: Open
    - Source: Gateway
      Target: Service
      TargetArrowHead:
        Type: Open
    - Source: Service
      Target: Redis
      TargetArrowHead:
        Type: Open
    - Source: Service
      Target: Database
      TargetArrowHead:
        Type: Open