Linked Templates
Linked template deployments allow you to decompose complex infrastructure into smaller, reusable projects.
ChildProjectInstance
Section titled “ChildProjectInstance”Use ChildProjectInstance from the core package to deploy a child project as a linked ARM template deployment:
import { ChildProjectInstance } from "@intentius/chant";
export const networkDeploy = new ChildProjectInstance({ project: "../network", parameters: { vnetName: "my-vnet", addressPrefix: "10.0.0.0/16", },});This generates a Microsoft.Resources/deployments resource in the parent template that references the child template.
Multi-project architecture
Section titled “Multi-project architecture”A typical multi-project setup:
infrastructure/├── network/ # VNet, subnets, NSGs│ └── src/main.ts├── data/ # Storage, SQL, Key Vault│ └── src/main.ts├── compute/ # VMs, AKS, App Service│ └── src/main.ts└── main/ # Orchestrator — deploys all sub-projects └── src/main.tsThe orchestrator project:
import { ChildProjectInstance } from "@intentius/chant";
export const networkDeploy = new ChildProjectInstance({ project: "../network", parameters: { vnetName: "prod-vnet", addressPrefix: "10.0.0.0/16", },});
export const dataDeploy = new ChildProjectInstance({ project: "../data", parameters: { storageName: "prodstorage01", sqlServerName: "prod-sql", },});
export const computeDeploy = new ChildProjectInstance({ project: "../compute", parameters: { aksClusterName: "prod-aks", },});Cross-project references
Section titled “Cross-project references”Reference outputs from a child deployment in the parent:
import { ChildProjectInstance, StackOutput } from "@intentius/chant";import { Reference } from "@intentius/chant-lexicon-azure";
export const networkDeploy = new ChildProjectInstance({ project: "../network", parameters: { vnetName: "my-vnet" },});
// Reference the child deployment's outputsexport const vnetId = new StackOutput({ name: "vnetId", value: Reference("networkDeploy").outputs.vnetId.value,});Deployment modes
Section titled “Deployment modes”ARM linked deployments support two modes:
- Incremental (default) — Adds or updates resources, leaves others unchanged
- Complete — Adds or updates resources and removes any not in the template
The deployment mode is configured at the Azure CLI level:
# Incremental (default, safe)az deployment group create --mode Incremental --template-file dist/template.json
# Complete (careful — removes unlisted resources)az deployment group create --mode Complete --template-file dist/template.json