Back to Home
Documentation

Reference

YAML Reference

Detailed reference for the DAC YAML structure, core fields, primitives, and best practices.

The DAC schema is intentionally compact. Most diagrams are defined with three core concepts: DefinitionFiles, Resources, and Links.

Core fields

FieldMeaning
Diagram.DefinitionFilesDefinition source for icon metadata and presets
Resources.<name>.TypeAWS resource type or diagram primitive
Resources.<name>.ChildrenChild resources placed inside a container
Resources.<name>.DirectionLayout direction for children, usually vertical or horizontal
Resources.<name>.PresetNamed visual preset from the definition file
Resources.<name>.TitleDisplay label override
Resources.<name>.BorderChildrenResources attached to the border of a container
Links[].Source / TargetLogical connection between resource names
Links[].Labels.*.TitleOptional label placed around the edge
Links[].TargetArrowHead.TypeArrow style such as Open, Default, or none

Common primitives

TypePurpose
AWS::Diagram::CanvasRoot drawing surface
AWS::Diagram::CloudAWS cloud grouping container
AWS::EC2::VPCVPC container with child resources
AWS::EC2::SubnetSubnet container, often with PublicSubnet or PrivateSubnet preset
AWS::Diagram::HorizontalStackHorizontal layout wrapper
AWS::Diagram::VerticalStackVertical layout wrapper
AWS::Diagram::ResourceGeneric visual resource such as User or Mobile client

Best practices

  • Always keep a Canvas root and attach the real top-level nodes as its children.
  • Use stable YAML keys such as ALB, PublicSubnetA, OrdersService, and Redis.
  • Use groups like Cloud, VPC, and Subnet to make boundaries explicit.
  • Use Title only when the displayed label should differ from the YAML key.
  • If a diagram has too many crossing links, split it into multiple focused diagrams.

Reference example

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: [Cloud, User]

    Cloud:
      Type: AWS::Diagram::Cloud
      Preset: AWSCloudNoLogo
      Children: [VPC]

    VPC:
      Type: AWS::EC2::VPC
      Direction: vertical
      Children: [ALB, AppTier]
      BorderChildren:
        - Position: S
          Resource: IGW

    AppTier:
      Type: AWS::Diagram::HorizontalStack
      Children: [SubnetA, SubnetB]

    SubnetA:
      Type: AWS::EC2::Subnet
      Preset: PublicSubnet
      Children: [InstanceA]

    SubnetB:
      Type: AWS::EC2::Subnet
      Preset: PublicSubnet
      Children: [InstanceB]

    InstanceA:
      Type: AWS::EC2::Instance

    InstanceB:
      Type: AWS::EC2::Instance

    ALB:
      Type: AWS::ElasticLoadBalancingV2::LoadBalancer
      Preset: Application Load Balancer

    IGW:
      Type: AWS::EC2::InternetGateway

    User:
      Type: AWS::Diagram::Resource
      Preset: User

  Links:
    - Source: User
      Target: IGW
      TargetArrowHead:
        Type: Open
    - Source: IGW
      Target: ALB
      TargetArrowHead:
        Type: Open
    - Source: ALB
      Target: InstanceA
      TargetArrowHead:
        Type: Open
      Labels:
        SourceLeft:
          Title: "HTTP:80"
    - Source: ALB
      Target: InstanceB
      TargetArrowHead:
        Type: Open
      Labels:
        SourceRight:
          Title: "HTTP:80"