If we apply the same principle to ARM templates, we can adopt the practice of writing ARM templates that have a single responsibility and a single reason to change.
This means ARM templates should have either of the following:
- A single resource: Changes to this resource should be the only reason to change the ARM template.
- A group of related resources: This represents either a functional grouping or a technical grouping. These ARM templates can further use nested or linked templates. These templates can also be called intermediate templates.
Eventually, there is a master or a main template that brings all the intermediate and single resource templates together to form a solution. This composition of ARM templates is also shown in the following diagram:
The Master Template is the initiation template, and it invokes other templates. The other templates could be shared templates. Shared templates are templates that can be used across projects. They represent a technical solution such as the SQL Server environment, an App Service Environment, a messaging environment, or a data center comprising of virtual machines. The main template can then call intermediate templates, also known as configuration templates. The job of the intermediate templates is to compose leaf-level or single resource-level templates. These templates are called known configuration templates because they provide multiple options to the deployer. The deployer can choose from these options to create resources from these known configuration templates. For example, for creating a data center environment, the options provided could be small, medium, and large. Based on the value provided by the deployer, the template could provision a different number of virtual machines for small, medium, and large options. These options are also known as SKUs or T-shirt sizes.
These known configuration templates are created to provide flexibility to the deployer to create a different environment based on these SKUs, using the same ARM templates. This is shown in the next screenshot: