{
  "schemaVersion": "0.1",
  "diagramFamily": "architecture",
  "scene": {
    "id": "aws-architecture-from-terraform",
    "title": "Bookings platform on AWS (production)",
    "brief": "Production AWS architecture of the bookings platform, drawn from the Terraform in infra/production.\nDrawn as AWS reference diagrams are: aws.* group frames nested AWS Cloud > Region > VPC > Availability Zone > subnets, and one node per resource that runs or stores something, with its aws: icon, in the innermost group it runs in. Each AZ lists its public subnet first, then its app and data subnets. The Bookings API runs one task per AZ; its calls to regional services are drawn from the task in AZ B. Logging is one edge from the VPC to CloudWatch. Edges run from caller to callee. Leave layout off new elements: the engine places them. Each infrastructure pull request is recorded as a revision before terraform apply, its message starting with the PR number (PR 412: ...).",
    "units": "px",
    "canvas": {
      "width": 1600,
      "height": 1200,
      "background": "#1a1a22"
    }
  },
  "palette": {
    "background": "#1a1a22",
    "foreground": "#FFFFFF",
    "edgeStroke": "#8FA7C4",
    "mutedForeground": "#c9d1d9"
  },
  "elements": [
    { "id": "aws_cloud", "kind": "frame", "title": "AWS Cloud", "containerType": "aws.cloud", "children": ["route53", "cloudfront", "waf", "region"] },
    { "id": "region", "kind": "frame", "title": "Region us-east-1", "containerType": "aws.region", "children": ["vpc", "cognito", "s3_assets", "s3_uploads", "cloudwatch", "sqs", "worker"] },
    { "id": "vpc", "kind": "frame", "title": "VPC 10.0.0.0/16", "containerType": "aws.vpc", "children": ["igw", "alb", "az_a", "az_b"] },
    { "id": "az_a", "kind": "frame", "title": "Availability Zone A", "containerType": "aws.az", "children": ["pub_a", "app_a", "data_a"] },
    { "id": "az_b", "kind": "frame", "title": "Availability Zone B", "containerType": "aws.az", "children": ["pub_b", "app_b", "data_b"] },
    { "id": "pub_a", "kind": "frame", "title": "Public subnet", "containerType": "aws.subnet.public", "children": ["nat_a"] },
    { "id": "pub_b", "kind": "frame", "title": "Public subnet", "containerType": "aws.subnet.public", "children": ["nat_b"] },
    { "id": "app_a", "kind": "frame", "title": "Private subnet (app)", "containerType": "aws.subnet.private", "children": ["svc_a"] },
    { "id": "app_b", "kind": "frame", "title": "Private subnet (app)", "containerType": "aws.subnet.private", "children": ["svc_b"] },
    { "id": "data_a", "kind": "frame", "title": "Private subnet (data)", "containerType": "aws.subnet.private", "children": ["cache_a", "aurora_w"] },
    { "id": "data_b", "kind": "frame", "title": "Private subnet (data)", "containerType": "aws.subnet.private", "children": ["aurora_r", "cache_b"] },
    { "id": "users", "kind": "node", "nodeType": "actor", "label": "Customers", "icon": "aws:users" },
    { "id": "route53", "kind": "node", "nodeType": "service", "label": "Amazon Route 53", "icon": "aws:route53" },
    { "id": "cloudfront", "kind": "node", "nodeType": "service", "label": "Amazon CloudFront", "icon": "aws:cloudfront" },
    { "id": "waf", "kind": "node", "nodeType": "service", "label": "AWS WAF", "icon": "aws:waf" },
    { "id": "igw", "kind": "node", "nodeType": "service", "label": "Internet gateway", "icon": "aws:internet-gateway" },
    { "id": "alb", "kind": "node", "nodeType": "service", "label": "Application Load Balancer", "icon": "aws:application-load-balancer" },
    { "id": "nat_a", "kind": "node", "nodeType": "service", "label": "NAT gateway", "icon": "aws:nat-gateway" },
    { "id": "nat_b", "kind": "node", "nodeType": "service", "label": "NAT gateway", "icon": "aws:nat-gateway" },
    { "id": "svc_a", "kind": "node", "nodeType": "service", "label": "Bookings API task", "icon": "aws:ecs-task" },
    { "id": "svc_b", "kind": "node", "nodeType": "service", "label": "Bookings API task", "icon": "aws:ecs-task" },
    { "id": "cache_a", "kind": "node", "nodeType": "database", "label": "ElastiCache primary", "icon": "aws:elasticache" },
    { "id": "aurora_w", "kind": "node", "nodeType": "database", "label": "Aurora writer", "icon": "aws:aurora" },
    { "id": "aurora_r", "kind": "node", "nodeType": "database", "label": "Aurora reader", "icon": "aws:aurora" },
    { "id": "cache_b", "kind": "node", "nodeType": "database", "label": "ElastiCache replica", "icon": "aws:elasticache" },
    { "id": "cognito", "kind": "node", "nodeType": "service", "label": "Amazon Cognito", "icon": "aws:cognito" },
    { "id": "s3_assets", "kind": "node", "nodeType": "objectStorage", "label": "S3 web assets", "icon": "aws:s3" },
    { "id": "s3_uploads", "kind": "node", "nodeType": "objectStorage", "label": "S3 uploads", "icon": "aws:s3" },
    { "id": "cloudwatch", "kind": "node", "nodeType": "service", "label": "Amazon CloudWatch", "icon": "aws:cloudwatch" },
    { "id": "sqs", "kind": "node", "nodeType": "queue", "label": "Amazon SQS", "icon": "aws:sqs" },
    { "id": "worker", "kind": "node", "nodeType": "service", "label": "AWS Lambda worker", "icon": "aws:lambda" },
    { "id": "e_dns", "kind": "edge", "from": { "elementId": "users" }, "to": { "elementId": "route53" }, "label": "DNS" },
    { "id": "e_https", "kind": "edge", "from": { "elementId": "users" }, "to": { "elementId": "cloudfront" }, "label": "HTTPS" },
    { "id": "e_signin", "kind": "edge", "from": { "elementId": "users" }, "to": { "elementId": "cognito" }, "label": "sign in" },
    { "id": "e_waf", "kind": "edge", "from": { "elementId": "waf" }, "to": { "elementId": "cloudfront" }, "style": { "dash": [6, 4] }, "endpoints": { "endArrow": "none" } },
    { "id": "e_static", "kind": "edge", "from": { "elementId": "cloudfront" }, "to": { "elementId": "s3_assets" }, "label": "static files" },
    { "id": "e_api", "kind": "edge", "from": { "elementId": "cloudfront" }, "to": { "elementId": "igw" }, "label": "/api/*" },
    { "id": "e_igw", "kind": "edge", "from": { "elementId": "igw" }, "to": { "elementId": "alb" } },
    { "id": "e_alb_a", "kind": "edge", "from": { "elementId": "alb" }, "to": { "elementId": "svc_a" } },
    { "id": "e_alb_b", "kind": "edge", "from": { "elementId": "alb" }, "to": { "elementId": "svc_b" } },
    { "id": "e_cache_a", "kind": "edge", "from": { "elementId": "svc_a" }, "to": { "elementId": "cache_a" } },
    { "id": "e_sql_a", "kind": "edge", "from": { "elementId": "svc_a" }, "to": { "elementId": "aurora_w" } },
    { "id": "e_sql_b", "kind": "edge", "from": { "elementId": "svc_b" }, "to": { "elementId": "aurora_w" }, "label": "writes" },
    { "id": "e_read_b", "kind": "edge", "from": { "elementId": "svc_b" }, "to": { "elementId": "aurora_r" }, "label": "reads" },
    { "id": "e_cache_b", "kind": "edge", "from": { "elementId": "svc_b" }, "to": { "elementId": "cache_b" } },
    { "id": "e_repl_db", "kind": "edge", "from": { "elementId": "aurora_w" }, "to": { "elementId": "aurora_r" }, "label": "replication", "style": { "dash": [6, 4] } },
    { "id": "e_repl_cache", "kind": "edge", "from": { "elementId": "cache_a" }, "to": { "elementId": "cache_b" }, "label": "replication", "style": { "dash": [6, 4] } },
    { "id": "e_logs", "kind": "edge", "from": { "elementId": "vpc" }, "to": { "elementId": "cloudwatch" }, "label": "logs, metrics" },
    { "id": "e_upload", "kind": "edge", "from": { "elementId": "svc_b" }, "to": { "elementId": "s3_uploads" }, "label": "originals" },
    { "id": "e_enqueue", "kind": "edge", "from": { "elementId": "svc_b" }, "to": { "elementId": "sqs" }, "label": "enqueue" },
    { "id": "e_trigger", "kind": "edge", "from": { "elementId": "sqs" }, "to": { "elementId": "worker" }, "label": "invokes" },
    { "id": "e_write", "kind": "edge", "from": { "elementId": "worker" }, "to": { "elementId": "s3_uploads" }, "label": "thumbnails" }
  ]
}
