Deployment views
Deployment views allow you to visualize the deployment model, using same approach as model views — predicates.
View definition
Section titled “View definition”deployment { environment prod { zone eu { zone zone1 { instanceOf frontend.ui instanceOf backend.api } zone zone2 { instanceOf frontend.ui instanceOf backend.api } instanceOf database } }}views { deployment view index { title 'Production Deployment' link https://likec4.dev
include prod.** // ... }}View predicates
Section titled “View predicates”Deployment views are based on same predicates as model views.
But they refer to deployment nodes and instances.
Navigation
Section titled “Navigation”Use navigateTo inside an element with expression to open another view from a deployment node or instance:
views { deployment view prod { include server with { navigateTo server_deployment } }
deployment view server_deployment { include server.* }}The target must be an existing view.
Filtering
Section titled “Filtering”Filtering in deployment views uses the same principles as in normal views but takes into account deployment nodes, relations, tags and metadata defined in deployment model. When condition on element is checked the following rules are applied:
- For deployment instances, tags are combined from tags defined in model and tags defined in deployment model
- For a child of deployment instance the tags defined on child in model are used
- For a deployment node the tags defined in deployment model are used
- For deployment instances, the kind of the model element is used
- For a child of deployment instance the kind of this child is used
- For a deployment node the kind of this deployment node is used
- For deployment instances, metadata defined in deployment model replaces metadata from the model element
- For relationship endpoints,
source.metadata.*andtarget.metadata.*use the same deployed instance metadata rules - For deployment nodes, metadata defined in deployment model is used
- Tags are not inherited from parent nodes/elements
specification { element system element component deploymentNode environment deploymentNode zone tag next tag alpha tag beta tag gamma tag sigma tag delta}model { cloud = system { frontend = component { #next -> backend "rel1" } backend = component { #next -> db "rel2" } db = component }}deployment { environment prod { // Resulting tags: #alpha #alpha zone eu { // Resulting tags: #beta #beta instanceOf cloud.frontend { // Resulting tags: #next, #gamma #gamma } instanceOf cloud.backend { // Resulting tags: #next, #sigma #sigma } eu -> prod.db "rel3" } instanceOf cloud.db { // Resulting tags: #delta #delta } }}views { deployment view some { include prod.eu.frontend -> prod.eu.backend where source.tag is #next // includes relation "rel1" include prod.eu.frontend -> prod.eu.backend where source.tag is #gamma // includes relation "rel1" include prod.eu -> prod.db where source.tag is #beta // includes relation "rel3" include prod.eu -> prod.db where source.tag is #sigma // does not include any relations include prod.eu.* -> prod.db where source.tag is #sigma // includes relation "rel2" }}Metadata predicates can be used with include and exclude as well:
deployment { environment prod { instanceOf backend { metadata { zone 'public' } } instanceOf database { metadata { zone 'restricted' } } }}
views { deployment view prod { include * -> * exclude * -> * where target.metadata.zone is "restricted" }}Groups
Section titled “Groups”Use group to draw a boundary around deployment nodes or instances, without changing the deployment model:
deployment view production { group 'European zones' { color amber border solid opacity 20%
include prod.eu.zone1, prod.eu.zone2 }}Groups can be unnamed or nested, and can contain deployment include and exclude predicates.
They follow the same ordering rules as element groups.
Unlike element groups, deployment groups are inserted inside their shared visible deployment parent,
including ancestors added by includeAncestors true:
deployment view production { include prod group 'Layer 2' { include prod.app1, prod.app2 } group 'Layer 3' { include prod.api }}Here, both groups are inside prod, and the selected instances are inside their groups.
Members must share the same deployment parent. Selecting nodes under different parents is reported as
an error, even if those parents are not visible or share a common ancestor. Use separate groups within each
deployment container instead. This applies to relationship endpoints and selections inside nested groups as well.
If a parent and its descendants are selected in the same group, the group wraps the parent and preserves
its deployment hierarchy; the parent counts as the member when checking the shared-parent requirement.
Shared predicate groups and styles are not supported inside deployment groups.
Include ancestors
Section titled “Include ancestors”Sometimes, it’s useful to visualize exactly how elements are deployed. In this case, you can use
the includeAncestors attribute on a deployment view.
The purpose of this attribute is to force all ancestors of already visible elements to show in the final diagram. It will not affect the visible relationships. It’s just a representation preference allowing to view how each relevant element is deployed.
specification { element service
deploymentNode hypervisor { style { color green } } deploymentNode vm { style { color red } } deploymentNode app_server { style { color sky } }}
model { svc1 = service svc2 = service
svc1 -> svc2}
deployment { hyp1 = hypervisor { vm = vm { tomcat1 = app_server "tomcat" { instanceOf svc1 } } } hyp2 = hypervisor { vm = vm { tomcat2 = app_server "tomcat" { instanceOf svc2 } } }}
views { deployment view ancestors_test { includeAncestors true
include hyp1.vm.tomcat1.svc1 include hyp2.vm.tomcat2.svc2 }}