コンテンツにスキップ

YAML仕様

このドキュメントでは、アーキテクチャ図を定義するためのYAML DSL(ドメイン固有言語)について説明します。

ドキュメント構造

version: 1
docId: "unique-identifier"
title: "図のタイトル"
nodes:
- id: node1
provider: aws
kind: network.vpc
label: "マイVPC"
layout: { x: 0, y: 0, w: 800, h: 500 }
edges:
- id: edge1
from: node1
to: node2
label: "接続"

トップレベルプロパティ

プロパティ必須説明
versionnumberはいスキーマバージョン(現在は1
docIdstringはい一意のドキュメント識別子(WebSocketマッチングに使用)
titlestringいいえドキュメントタイトル(デフォルトはdocId
nodesarrayはいノード定義のリスト
edgesarrayいいえエッジ定義のリスト
iconsobjectいいえカスタムアイコンマッピング(カスタムアイコンを参照)

ノード

ノードはアーキテクチャ図のリソースを表します。

ノードプロパティ

プロパティ必須説明
idstringはい一意のノード識別子
providerstringはいクラウドプロバイダー(例: aws, gcp, azure
kindstringはいリソースタイプ(例: network.vpc, compute.lb.alb
labelstringいいえ表示ラベル(デフォルトはid
parentstringいいえネスト用の親ノードID
layoutobjectはい位置とサイズ

レイアウトプロパティ

プロパティ必須説明
layoutobject条件付き*位置とサイズ
layout.xnumber条件付き*X位置(ピクセル)
layout.ynumber条件付き*Y位置(ピクセル)
layout.wnumberいいえ**幅(ピクセル)
layout.hnumberいいえ**高さ(ピクセル)

*layoutlayout.xlayout.yトップレベルノードでは必須ですが、子ノードparentを持つノード)では省略可能です。オートレイアウトを参照。

**whはコンテナノード(VPC、Subnetなど)では任意。省略時はデフォルトが適用されます。

オートレイアウト

子ノード(parentを持つノード)はlayoutlayout.xlayout.yを省略できます。省略した場合、ノードは親内で3列のグリッドパターンで自動配置されます。

ルール:

  1. トップレベルノード: layoutxyが必須
  2. 子ノード(リーフ): layoutは省略可能。自動配置には省略
  3. コンテナノード: w/hは任意。省略時はデフォルトを使用。x/yは自動配置のため省略可能
  4. 部分的な座標: 許可されません。xyの両方を指定するか、両方を省略

グリッドレイアウト:

自動配置されるノードはグリッドで配置されます:

  • 1行に3列
  • 親エッジから60pxのパディング
  • 160pxの水平間隔
  • 140pxの垂直間隔
┌────────────────────────────────────────┐
│ [1] [2] [3] │
│ (60,60) (280,60) (500,60) │
│ │
│ [4] [5] [6] │
│ (60,260) (280,260) (500,260) │
└────────────────────────────────────────┘

例:

nodes:
# コンテナ: w/hを含む明示的なlayoutが必要
- id: vpc
provider: aws
kind: network.vpc
label: "VPC"
layout: { x: 0, y: 0, w: 800, h: 600 }
# コンテナの子: w/hが必要、x/yは自動配置可能
- id: subnet
provider: aws
kind: network.subnet
label: "プライベートサブネット"
parent: vpc
layout: { w: 700, h: 500 } # x/y自動: (40, 40)
# リーフノード: layoutを完全に省略可能
- id: ec2_1
provider: aws
kind: compute.ec2
label: "Webサーバー1"
parent: subnet
# layout省略 - 自動: (40, 40)
- id: ec2_2
provider: aws
kind: compute.ec2
label: "Webサーバー2"
parent: subnet
# layout省略 - 自動: (200, 40)
- id: rds
provider: aws
kind: database.rds
label: "データベース"
parent: subnet
# layout省略 - 自動: (360, 40)
# 明示的な配置はオートレイアウトを上書き
- id: lambda
provider: aws
kind: compute.lambda
label: "Lambda"
parent: subnet
layout: { x: 500, y: 300 } # カスタム位置

ノードの例

シンプルなリソース:

- id: alb
provider: aws
kind: compute.lb.alb
label: "Application Load Balancer"
layout: { x: 100, y: 100 }

コンテナ(VPC):

- id: vpc
provider: aws
kind: network.vpc
label: "VPC 10.0.0.0/16"
layout: { x: 0, y: 0, w: 800, h: 600 }

ネストされたノード:

- id: ecs
provider: aws
kind: compute.container.ecs_service
label: "ECS Service"
parent: subnet_private
layout: { x: 80, y: 120 }

エッジ

エッジはノード間の接続を表します。

エッジプロパティ

プロパティ必須説明
idstringはい一意のエッジ識別子
fromstringはい接続元ノードID
tostringはい接続先ノードID
labelstringいいえ接続ラベル(デフォルトは空)
colorstringいいえ線の色(HEX形式: #RGBまたは#RRGGBB)。デフォルトは#666666(グレー)

エッジの例

edges:
- id: alb_to_ecs
from: alb
to: ecs
label: "HTTP:80"
color: "#FF5733" # オレンジ
- id: ecs_to_rds
from: ecs
to: rds
label: "PostgreSQL:5432"
color: "#3498DB" # ブルー

エッジの色

colorプロパティでコネクタの線の色をカスタマイズできます:

  • 形式: #プレフィックス付きのHEXカラーコード
  • 短縮形: #RGB#RRGGBBに展開されます(例: #F00#FF0000になる)
  • デフォルト: #666666(グレー)
  • 大文字小文字: 大文字と小文字の両方を受け付けます

例:

edges:
# フルHEX形式
- id: e1
from: a
to: b
color: "#FF5733"
# 短縮形式
- id: e2
from: b
to: c
color: "#F53"
# 小文字
- id: e3
from: c
to: d
color: "#3498db"
# 色指定なし(デフォルトのグレーを使用)
- id: e4
from: d
to: e

サポートされるプロバイダー

Figramは複数のクラウドプロバイダーをサポートしています:

プロバイダー説明
awsAmazon Web Services
gcpGoogle Cloud Platform
azureMicrosoft Azure

サポートされるKind

各プロバイダーには、対応するアイコンを持つ独自のKindセットがあります。

AWS (provider: aws)

コンテナ(whが必要)

Kind説明
network.vpcVirtual Private Cloud
network.subnetサブネット

コンピューティングリソース

Kind説明
compute.ec2EC2インスタンス
compute.lambdaLambda関数
compute.lbElastic Load Balancing
compute.lb.albApplication Load Balancer
compute.lb.nlbNetwork Load Balancer
compute.container.ecsECSクラスター
compute.container.ecs_serviceECSサービス
compute.container.ecs_taskECSタスク
compute.container.eksEKSクラスター
compute.container.fargateFargate
compute.apprunnerApp Runner

データベースリソース

Kind説明
database.rdsRDSデータベース
database.auroraAurora
database.dynamodbDynamoDBテーブル
database.elasticacheElastiCache
database.neptuneNeptune
database.redshiftRedshift
database.documentdbDocumentDB

ストレージリソース

Kind説明
storage.s3S3バケット
storage.efsEFSファイルシステム
storage.ebsEBSボリューム
storage.glacierS3 Glacier

ネットワーキング

Kind説明
network.cloudfrontCloudFront
network.route53Route 53
network.apigatewayAPI Gateway
network.igwインターネットゲートウェイ
network.natgatewayNATゲートウェイ
network.transitgatewayTransit Gateway

インテグレーション

Kind説明
integration.sqsSQSキュー
integration.snsSNSトピック
integration.eventbridgeEventBridge
integration.stepfunctionsStep Functions

セキュリティ

Kind説明
security.iamIAM
security.cognitoCognito
security.secretsmanagerSecrets Manager
security.kmsKMS

GCP (provider: gcp)

コンテナ(whが必要)

Kind説明
network.vpcVirtual Private Cloud

コンピューティングリソース

Kind説明
compute.gceCompute Engine
compute.functionsCloud Functions
compute.cloudrunCloud Run
compute.container.gkeGoogle Kubernetes Engine
compute.appengineApp Engine
compute.lbCloud Load Balancing

データベースリソース

Kind説明
database.cloudsqlCloud SQL
database.spannerCloud Spanner
database.bigtableCloud Bigtable
database.firestoreFirestore
database.memorystoreMemorystore

ストレージリソース

Kind説明
storage.gcsCloud Storage
storage.filestoreFilestore

ネットワーキング

Kind説明
network.cdnCloud CDN
network.dnsCloud DNS
network.armorCloud Armor
network.natCloud NAT
network.apigatewayAPI Gateway

インテグレーション

Kind説明
integration.pubsubCloud Pub/Sub
integration.tasksCloud Tasks
integration.workflowsWorkflows

セキュリティ

Kind説明
security.iamCloud IAM
security.kmsCloud KMS
security.secretmanagerSecret Manager

Azure (provider: azure)

コンテナ(whが必要)

Kind説明
network.vnetVirtual Network

コンピューティングリソース

Kind説明
compute.vm仮想マシン
compute.functionsAzure Functions
compute.container.aciContainer Instances
compute.container.aksAzure Kubernetes Service
compute.appserviceApp Service
compute.lbLoad Balancer
compute.lb.appgwApplication Gateway

データベースリソース

Kind説明
database.sqlSQL Database
database.cosmosdbCosmos DB
database.mysqlAzure Database for MySQL
database.postgresqlAzure Database for PostgreSQL
database.redisAzure Cache for Redis

ストレージリソース

Kind説明
storage.storageストレージアカウント
storage.blobBlobストレージ
storage.filesファイルストレージ
storage.datalakeData Lake Storage

ネットワーキング

Kind説明
network.frontdoorAzure Front Door
network.cdnAzure CDN
network.dnsAzure DNS
network.firewallAzure Firewall
network.apimAPI Management

インテグレーション

Kind説明
integration.servicebusService Bus
integration.eventhubsEvent Hubs
integration.eventgridEvent Grid
integration.logicappsLogic Apps

セキュリティ

Kind説明
security.aadAzure Active Directory
security.keyvaultKey Vault
security.defenderMicrosoft Defender

カスタムKind

任意の文字列がkindとして受け入れられます。カテゴリ分けにはドット記法を使用:

- id: custom
provider: custom
kind: my.custom.resource
label: "カスタムリソース"
layout: { x: 0, y: 0 }

アイコンはKind階層を通じてフォールバックします。例えば、compute.lb.albは以下の順序で検索されます:

  1. compute.lb.alb(完全一致)
  2. compute.lb(親)
  3. compute(祖父母)

アイコンが見つからない場合は、汎用的な形状がレンダリングされます。

完全な例

version: 1
docId: "prod-architecture"
title: "本番環境アーキテクチャ"
nodes:
# VPCコンテナ
- id: vpc
provider: aws
kind: network.vpc
label: "VPC 10.0.0.0/16"
layout: { x: 0, y: 0, w: 960, h: 560 }
# パブリックサブネット
- id: subnet_public
provider: aws
kind: network.subnet
label: "パブリックサブネット (ap-northeast-1a)"
parent: vpc
layout: { x: 40, y: 80, w: 420, h: 360 }
# プライベートサブネット
- id: subnet_private
provider: aws
kind: network.subnet
label: "プライベートサブネット (ap-northeast-1a)"
parent: vpc
layout: { x: 500, y: 80, w: 420, h: 360 }
# パブリックサブネット内のALB
- id: alb
provider: aws
kind: compute.lb.alb
label: "ALB"
parent: subnet_public
layout: { x: 80, y: 140 }
# プライベートサブネット内のECS
- id: ecs
provider: aws
kind: compute.container.ecs_service
label: "ECSサービス"
parent: subnet_private
layout: { x: 80, y: 140 }
# プライベートサブネット内のRDS
- id: rds
provider: aws
kind: database.rds
label: "RDS PostgreSQL"
parent: subnet_private
layout: { x: 80, y: 280 }
edges:
- id: alb_to_ecs
from: alb
to: ecs
label: "HTTP:80"
- id: ecs_to_rds
from: ecs
to: rds
label: "PostgreSQL:5432"

バリデーションルール

IDの一意性

すべてのノードとエッジのIDはドキュメント内で一意である必要があります:

# 無効: 重複したID
nodes:
- id: server
# ...
- id: server # エラー: ノードIDが重複
# ...

親参照

parentフィールドは存在するノードを参照する必要があります:

# 無効: 親が存在しない
nodes:
- id: ecs
parent: nonexistent # エラー: 親 'nonexistent' が存在しません
# ...

循環検出

親関係は循環を形成できません:

# 無効: 循環を検出
nodes:
- id: a
parent: b
# ...
- id: b
parent: a # エラー: 循環を検出
# ...

エッジ参照

エッジのfromtoは存在するノードを参照する必要があります:

# 無効: ノードが存在しない
edges:
- id: e1
from: alb
to: nonexistent # エラー: to 'nonexistent' が存在しません

カスタムアイコン

ダイアグラムファイル内または別のfigram-icons.yamlファイルでカスタムアイコンを定義できます。

インラインアイコン

ダイアグラムファイルにアイコンを追加:

version: 1
docId: "prod"
icons:
aws:
"compute.ec2": "./icons/ec2.png"
"database.rds": "./icons/rds.png"
gcp:
"compute.gce": "./icons/gce.png"
nodes:
- id: web
provider: aws
kind: compute.ec2
# ...

アイコン構造

プロパティ説明
iconsobjectプロバイダーごとのアイコンマッピング
icons.<provider>objectプロバイダーのkind-to-pathマッピング
icons.<provider>.<kind>stringアイコンファイルへのパス(相対または絶対)

別ファイル(figram-icons.yaml)

別のアイコン設定ファイルを作成:

version: 1
icons:
aws:
"compute.ec2": "./icons/ec2.png"
"compute.lambda": "./icons/lambda.png"
"database.rds": "./icons/rds.png"

CLIはダイアグラムファイルと同じディレクトリにあるfigram-icons.yamlを自動的に検出します。

パス解決

  • 相対パス: YAMLファイルの場所から解決
  • 絶対パス: そのまま使用
  • 対応フォーマット: PNG, JPG, JPEG, GIF, WebP

階層フォールバック

アイコンは階層的なマッチングを使用します。親kindのアイコンを定義すると、すべての子に適用されます:

icons:
aws:
"compute": "./icons/compute-generic.png" # すべてのcompute.*のフォールバック
"compute.ec2": "./icons/ec2.png" # EC2専用

この設定では:

  • compute.ec2ec2.pngを使用
  • compute.lambdacompute-generic.pngを使用(親にフォールバック)
  • compute.container.ecscompute-generic.pngを使用(祖父にフォールバック)

ベストプラクティス

1. 説明的なIDを使用

# 良い例
- id: vpc_production
- id: subnet_public_a
- id: alb_web
# 避けるべき例
- id: n1
- id: n2

2. 一貫したレイアウトで整理

ネストされたノードは親からの相対位置で配置:

- id: vpc
layout: { x: 0, y: 0, w: 800, h: 500 }
- id: subnet
parent: vpc
layout: { x: 40, y: 60, w: 360, h: 380 } # 親からのオフセット
- id: alb
parent: subnet
layout: { x: 80, y: 120 } # サブネットからのオフセット

3. 意味のあるラベルを使用

# 良い例
- id: alb
label: "ALB (インターネット向け)"
# これも良い: IDが説明的な場合はラベルを省略
- id: "Application Load Balancer"
# labelはidがデフォルト

4. 関連するエッジをグループ化

edges:
# Webティア接続
- id: client_to_alb
from: client
to: alb
- id: alb_to_ecs
from: alb
to: ecs
# データティア接続
- id: ecs_to_rds
from: ecs
to: rds
- id: ecs_to_cache
from: ecs
to: elasticache