Create a Grouped Workers architecture diagram on AWS
This example demonstrates a basic AWS architecture with a Load Balancer distributing traffic to multiple EC2 worker instances, which then connect to an RDS database. It shows how to use the
direction option in the Diagram constructor to set the layout flow (e.g., 'TB' for Top-to-Bottom).import { Diagram } from "diagrams-js";
import { EC2 } from "diagrams-js/aws/compute";
import { RDS } from "diagrams-js/aws/database";
import { ELB } from "diagrams-js/aws/network";
const diagram = Diagram("Grouped Workers", {
direction: "TB",
});
const lb = diagram.add(ELB("lb"));
const workers = [
diagram.add(EC2("worker1")),
diagram.add(EC2("worker2")),
diagram.add(EC2("worker3")),
diagram.add(EC2("worker4")),
diagram.add(EC2("worker5")),
];
const events = diagram.add(RDS("events"));
lb.to(workers);
workers.forEach((w) => w.to(events));
const svg = await diagram.render();