Writing Operator Guides
An operator guide is a runbook for the instances of a bundle. Put it in operator.md at the bundle root. mass bundle publish includes it, and Massdriver renders it on each instance's Guide tab with that instance's configuration, dependencies, and resources filled in.
Template engine​
Set the engine in YAML front matter at the top of operator.md:
---
templating: mustache
---
templating | Engine |
|---|---|
mustache | Logic-less Mustache: variables, sections, inverted sections |
liquid | Liquid: conditionals, filters, and tags |
Without front matter, or with any other value, the guide is shown as written, with no interpolation.
Context​
| Variable | Contents | Example |
|---|---|---|
id | Instance id | ecomm-prod-api |
params.<field> | The instance's configuration | {{params.database_name}} |
params.md_metadata.<field> | Deployment metadata | {{params.md_metadata.name_prefix}} |
dependencies.<field>.<...> | Payload of the resource connected to each dependency | {{dependencies.network.specs.aws.region}} |
resources.<field>.<...> | Payload of each resource this instance produced | {{resources.database.data.infrastructure.arn}} |
dependencies includes resources connected by a link, an environment default, or a remote reference. The shape of each payload is the schema of its resource type. Many cloud types split fields into specs (metadata such as region) and data (connection details such as ARNs and hostnames); check the resource type's schema for the exact layout.
slug, connections, and artifacts are deprecated aliases for id, dependencies, and resources. They still render.
params.md_metadata​
| Field | Contents |
|---|---|
name_prefix | The instance's name prefix, for naming cloud resources |
default_tags | The tags for cloud resources. The keys depend on the organization's default tags setting. |
observability.alarm_webhook_url | Webhook URL for sending alarms to Massdriver |
package.created_at, package.updated_at | When the instance was created and last updated |
package.deployment_enqueued_at | When the guide was rendered |
package.previous_status | The instance's status |
target.contact_email | Email of the account viewing the guide |
md_metadata is built when the guide renders, so the deployment-time fields describe the current view, not the last deployment.
Sensitive fields​
Fields marked $md.sensitive: true in a resource type's schema render as [SENSITIVE]. A sensitive object keeps its keys with each value replaced, and a sensitive array becomes a list of [SENSITIVE]. Print ARNs, regions, hostnames, and ports; do not reference credentials.
Missing keys​
Both engines render a missing key as an empty string.
Mustache​
Instance: {{id}}
{{#dependencies.database}}
Database host: {{data.infrastructure.hostname}}
{{/dependencies.database}}
{{^dependencies.database}}
No database connected.
{{/dependencies.database}}
{{#params.subnets}}
- {{name}}: {{cidr}}
{{/params.subnets}}
{{! A comment that does not render }}
{{#name}} renders when the value is truthy and iterates over lists. {{^name}} renders when it is falsy.
Liquid​
{% if params.enable_ssl %}
SSL is enabled on port {{ params.ssl_port }}
{% else %}
SSL is not enabled
{% endif %}
Instance: {{ id | upcase }}
Example​
---
templating: mustache
---
# {{id}} runbook
- **Name prefix:** `{{params.md_metadata.name_prefix}}`
- **Version:** `{{params.version}}`
## Network
{{#dependencies.network}}
- **Region:** `{{specs.aws.region}}`
- **VPC:** `{{data.infrastructure.arn}}`
{{/dependencies.network}}
{{^dependencies.network}}
No network connected.
{{/dependencies.network}}
## Outputs
- **Function:** `{{resources.fn.data.infrastructure.arn}}`
## Commands
```bash
aws logs tail /aws/lambda/{{params.md_metadata.name_prefix}} --follow
mass instance deploy {{id}}
```
Guidelines​
- Use the field names from your bundle's
massdriver.yamland resource types. - Write commands that work when pasted, with values interpolated instead of
<replace-me>placeholders. - Cover the common operations: connecting, checking health, and troubleshooting.
- Update the guide when you change the schema.
- After a deployment, open the instance's Guide tab and check that every variable rendered.