Skip to main content

Massdriver Custom Annotations

Massdriver adds JSON Schema keywords prefixed with $md.:

AnnotationUsed inEffect
$md.immutableBundle paramsField is read-only once the instance is provisioned.
$md.enumBundle paramsDropdown built from a dependency's resource data.
$md.listBundle paramsDropdown of groups, service accounts, or projects in the organization.
$md.copyableBundle paramsWhether a field is copied to another instance.
$md.sensitiveResource type schemaField is masked in the API and UI.

$md.immutable​

Makes a field read-only after the instance is provisioned. Use it for values whose change would recreate the cloud resource, such as a VPC CIDR, a database identifier, or a bucket name.

yaml
properties:
cidr:
title: CIDR Range
description: IP address range for the VPC (cannot be changed after creation)
type: string
pattern: "^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}/[0-9]{1,2}$"
$md.immutable: true
name:
title: VPC Name
type: string
$md.immutable: true
enable_dns:
title: Enable DNS
type: boolean
default: true

When the instance's status is provisioned or failed, Massdriver replaces $md.immutable with the standard readOnly keyword in the instance's params schema. In any other status, such as before the first deployment or after a decommission, the field is editable.

It works on top-level properties and on properties nested in objects.

$md.enum​

Builds a dropdown from the data of a resource that fills one of the bundle's dependencies, such as the subnets of a connected VPC.

KeyRequiredDescription
dependencyYesName of a dependency in the bundle's dependencies block.
connectionNoDeprecated name for dependency. When both are set, dependency wins.
optionsYesjq filter that returns the options as an array, run against the resource's payload.
valueNojq filter for each option's saved value. Default ..
labelNojq filter for each option's label. Default: the value filter.

The payload has the shape of the dependency's resource type schema.

Example: Array of Strings​

yaml
dependencies:
postgres_cluster:
resource_type: postgresql-cluster@~1
required: true

params:
required:
- database_instance
properties:
database_instance:
title: Database Instance
type: string
$md.enum:
dependency: postgres_cluster
options: .instances

Each string in instances is both the value and the label.

Example: Objects with Labels​

yaml
dependencies:
vpc:
resource_type: aws-vpc@~1
required: true

params:
required:
- subnet_id
properties:
subnet_id:
title: Subnet
type: string
$md.enum:
dependency: vpc
options: .infrastructure.subnets
value: .id
label: '"\(.name) - \(.cidr) (\(.availability_zone))"'

Each subnet saves its id, and its label reads like Private Subnet 1 - 10.0.1.0/24 (us-east-1a).

Behavior​

Massdriver resolves $md.enum when it returns the instance's params schema:

  1. Reads the payload of the resource that fills the dependency.
  2. Runs options against it. The result must be an array. A result of null gives an empty dropdown.
  3. Runs value and label against each item.
  4. Replaces $md.enum with a oneOf of const (value) and title (label) pairs, sorted by title.

When the options cannot be built, the dropdown has one option with no value that shows the error:

  • ERROR: Dependency not found: <name>: the dependency is not filled.
  • ERROR: Dependency could not be read: <name>
  • ERROR: jq expression error: <error>
  • ERROR: The jq expression in `options` returned single value instead of array: <value>

A field with $md.enum is not copied to another instance unless it also sets $md.copyable: true. See $md.copyable.

$md.list​

A dropdown of the groups, service accounts, or projects in your organization, such as the group that owns a database and gets paged for its alarms, the service account a CI pipeline deploys with, or the project a shared resource is charged to.

resourceOptionsSaved value
groupEvery group in the organizationGroup UUID
service_accountEvery service account, when the user has organization:manageServiceAccounts. Other users see no options.Service account UUID
projectThe projects the user has project:view onProject identifier

Each user sees the options they can view, so two users can see different lists for the same field.

Values the user cannot view. An instance can store a value that the current user cannot view, such as a project someone else picked. The value stays in the dropdown with the title You cannot view this project (or group, or service account). The user can keep it, remove it, or replace it.

Saving. A save can keep or remove any stored value. Every value a save adds must be one the user can view. Otherwise the save fails:

references project secret, which you cannot select

The same check applies when you copy an instance's params or fork an environment. Fields with $md.copyable: false are not copied, so they are not checked.

Deploying. A deployment does not check stored values again. If a user loses access to a project after picking it, or a picked group is deleted, the stored ID stays in params. Bundle code must handle an ID that no longer exists.

Example: Single Pick​

yaml
properties:
owner_project:
title: Owning Project
description: The project this shared database is charged to
type: string
$md.list:
resource: project

Example: Multi Pick​

Put $md.list on items:

yaml
properties:
on_call_teams:
title: On-call Teams
description: Groups paged for this database's alarms
type: array
items:
type: string
$md.list:
resource: group

Publish Validation​

mass bundle publish fails when a $md.list declaration is not valid. Each error gives the JSON pointer to the field:

$md.list at #/properties/owner_project: resource must be one of group, service_account, project

A declaration is not valid when:

  • resource is missing or is not group, service_account, or project.
  • It has a key other than resource.
  • The field's type is not string. For a multi pick, put $md.list on items.
  • The field also sets enum, const, default, or oneOf.

When Massdriver returns the instance's params schema, it replaces $md.list with a oneOf of const (ID) and title (name) pairs: the values the user can view, plus every stored value they cannot.

$md.copyable​

Controls whether a field is copied when params move from one instance to another:

$md.copyable: false leaves the field out of the copy. Without the annotation, a field is copied, except a field with $md.enum, whose options usually depend on the source environment. Set $md.copyable: true to copy it anyway.

The check recurses into nested objects that declare properties. It does not stop anyone from editing the field.

yaml
properties:
name:
title: Database Name
type: string
size:
title: Instance Size
type: string
enum: ["small", "medium", "large"]
admin_password:
title: Admin Password
type: string
format: password
$md.copyable: false
database:
title: Database Settings
type: object
properties:
username:
title: Username
type: string
password:
title: Database Password
type: string
format: password
$md.copyable: false
host:
title: Database Host
type: string

copyInstance copies params between two instances of the same component, deep-merging overrides on top:

graphql
mutation {
copyInstance(
organizationId: "my-org"
sourceId: "ecomm-prod-db"
destinationId: "ecomm-staging-db"
input: {
overrides: {
name: "staging-database"
size: "small"
database: { host: "staging-db.example.com", password: "new-staging-password" }
}
}
) {
successful
result { id params }
}
}

The destination gets name, size, and database.host from overrides, database.username from the source, and database.password from overrides. admin_password is not copied, so it stays unset until someone sets it.

Mark secrets such as passwords, API keys, tokens, and certificates $md.copyable: false.

$md.sensitive​

Used in a resource type's schema. Masks a field's value when a resource is read through the API or shown in the UI. Resources are encrypted at rest and in transit either way. A deployment gets the full values.

yaml
schema:
type: object
properties:
username:
type: string
password:
type: string
$md.sensitive: true
connection_string:
type: string
$md.sensitive: true
infrastructure:
type: object
properties:
arn:
type: string

The resource's payload field returns:

json
{
"username": "admin",
"password": "[SENSITIVE]",
"connection_string": "[SENSITIVE]",
"infrastructure": {
"arn": "arn:aws:rds:us-east-1:123456789012:db:mydb"
}
}
  • A sensitive scalar becomes "[SENSITIVE]".
  • A sensitive object keeps its keys, and each value becomes "[SENSITIVE]".
  • A sensitive array keeps its length, and each item becomes "[SENSITIVE]".
  • Masking recurses into properties with type: object and into arrays of objects.

Write the key as $md.sensitive: true. A nested $md: {sensitive: true} map is not read.

To read the unmasked payload, use the exportResource mutation. It requires resource:export, and each call is recorded in the audit log.

graphql
mutation {
exportResource(organizationId: "my-org", id: "<resource-id>") {
successful
result { id payload }
}
}

Combining Annotations​

yaml
dependencies:
vpc:
resource_type: aws-vpc@~1
required: true

params:
required:
- identifier
- admin_password
properties:
identifier:
title: Database Identifier
type: string
pattern: "^[a-z][a-z0-9-]*$"
$md.immutable: true
subnet_id:
title: Subnet
type: string
$md.enum:
dependency: vpc
options: .infrastructure.private_subnets
value: .id
label: '"\(.name) (\(.availability_zone))"'
admin_password:
title: Admin Password
type: string
format: password
$md.immutable: true
$md.copyable: false

identifier cannot change after creation. subnet_id lists the subnets of the connected VPC and is not copied to other instances. admin_password cannot change after creation and is never copied.