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
| Field | Meaning |
|---|---|
| Diagram.DefinitionFiles | Definition source for icon metadata and presets |
| Resources.<name>.Type | AWS resource type or diagram primitive |
| Resources.<name>.Children | Child resources placed inside a container |
| Resources.<name>.Direction | Layout direction for children, usually vertical or horizontal |
| Resources.<name>.Preset | Named visual preset from the definition file |
| Resources.<name>.Title | Display label override |
| Resources.<name>.BorderChildren | Resources attached to the border of a container |
| Links[].Source / Target | Logical connection between resource names |
| Links[].Labels.*.Title | Optional label placed around the edge |
| Links[].TargetArrowHead.Type | Arrow style such as Open, Default, or none |
Common primitives
| Type | Purpose |
|---|---|
| AWS::Diagram::Canvas | Root drawing surface |
| AWS::Diagram::Cloud | AWS cloud grouping container |
| AWS::EC2::VPC | VPC container with child resources |
| AWS::EC2::Subnet | Subnet container, often with PublicSubnet or PrivateSubnet preset |
| AWS::Diagram::HorizontalStack | Horizontal layout wrapper |
| AWS::Diagram::VerticalStack | Vertical layout wrapper |
| AWS::Diagram::Resource | Generic 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"