Nodes

A node is the most basic building block in a cloud architecture diagram.

Node definitions consist of a name followed by an optional set of properties. For example, compute is the name of below node and it has an icon property which is set to aws-ec2.

compute [icon: aws-ec2]

Node names are required to be unique.

Nodes support icon and color properties.

Groups

A group is a container that can encapsulate nodes and groups.

Group definitions consist of a name followed by { }. For example, Main Server is the name of the below group and it contains Server and Data nodes.

  Main Server {
    Server [icon: aws-ec2]
    Data [icon: aws-rds]
  }

Group names are required to be unique.

Groups can be nested. In the below example, VPC Subnet group contains Main Server group.

VPC Subnet {
  Main Server {
    Server [icon: aws-ec2]
    Data [icon: aws-rds]
  }
}

Groups support icon and color properties.

Properties

Properties are key-value pairs enclosed in [ ] brackets that can be appended to definitions of nodes and groups. Properties are optional.

It is possible to set multiple properties like shown below:

  Main Server [icon: aws-ec2, color: blue] {
    Server [icon: aws-ec2]
    Data [icon: aws-rds]
  }

Here are the properties that are allowed:

PropertyDescriptionValue
IconAttached iconsIcon names (e.g. aws-ec2). See Icons page for full list.
ColorStroke and fill color, when possibleColor name (e.g. blue) or hex code (e.g. #000000)

Here are the lists of icon names:

Connections

Connections represent relationships between nodes and groups. They can be created between nodes, between groups, and between nodes and groups.

Here is an example of a connection between two nodes:

Compute > Storage

Here are the types of connectors:

Connector Syntax Description
> Left-to-right arrow
< Right-to-left arrow
<> Bi-directional arrow
- Line
-- Dotted line
--> Dotted arrow

It is possible to add a label to a connection. Here is an example:

Storage > Server: Cache Hit

It is possible to create it is possible to create one-to-many connections in a single statement. This is instead of creating separate one-to-one connections. Here is an example:

Server > Worker1, Worker2, Worker3

If a connection statement contains a name that has not been previously defined as a node or a group, a blank node with that name will be created.

Icons

Here's a list of all the icons you can use with diagram-as-code.

Escape string

Certain characters are not allowed in node and group names because they are reserved. You can use these characters, you can wrap the entire node or group name in quotes " ".

User > "https://localhost:8080": GET

Direction

The direction of the cloud architecture diagram can be changed using the direction statement. Allowed directions are:

  • direction down
  • direction up
  • direction right (default)
  • direction left

The direction statement can be placed anywhere in the code like this:

direction down