Block templates
A block template combines a Terraform module, a form schema, and optional JavaScript validation. It belongs to an infrastructure and is available to that infrastructure’s scopes. Each block is an instance of one template.
Create a template
On the infrastructure, create a block template and configure:
| Setting | Meaning |
|---|---|
| Name | 1–100 characters; starts with a letter or _, then letters, digits, or _. |
| IaC data source | Source owned by the infrastructure’s owning team. |
| IaC path | Module directory relative to the source, or . for its root. |
| Form fields | Array describing the block form and module inputs. |
| Validator | Optional JavaScript file and user context. |
For example, choose platform-modules, module path modules/network, and name network. Paths must remain inside
the source. Saving a template does not initialize or plan its Terraform module, so a correct-looking template can
still fail when a consumer calculates a diff.
The module is instantiated using the block’s stored name as its Terraform module label. Ordinary fields become module input arguments. Provider fields produce provider bindings; block fields produce references to another block’s module output.
Define the form
Use the form editor or its YAML/JSON representation. A minimal schema is:
- name: cidr
type: string
mode: required
description: Network CIDR
- name: enabled
type: boolean
mode: optional
default: trueThe module must accept the corresponding cidr and enabled variables. Field names are unique within a template.
An empty array is valid for a module with no form inputs; null is not.
See form fields reference for every supported field type, mode, default, and constraint.
Add validation
Enable the validator, choose its data source and JavaScript file, and optionally provide a Validator user context object. The validator source must also belong to the infrastructure’s owning team.
Validator code is executed each time before a block gets created/updated. The goal of a validator is to check the data before it is saved.
Validator is not executed during the diff/apply workflows.
For complete examples, see block validation and the validation API client reference. Check that the file has actually been imported before making the template available; missing validator code must not be treated as a tested validation rule.
Evolve a template
Existing blocks keep a reference to the template. Changes can therefore affect later validation and Terraform plans for existing blocks. Coordinate field renames, new required inputs, output changes, and module changes with consumers, then review affected scopes.
A template that refers to other templates through block fields must avoid dependency cycles. Provider types referenced by its provider fields must belong to the same infrastructure. Use block dependencies and blocks with multiple providers for these cases.
Deletion previews identify referencing blocks and other dependencies. Remove or change references deliberately; deleting a template is not an instruction to destroy resources.
A template cannot be deleted while a block uses it or while a block uses a template that depends on it. Delete or change those blocks first.